From 48c2a4fda86fb08fd27473a6e47fe039d683e200 Mon Sep 17 00:00:00 2001 From: Andrew Schoen Date: Mon, 30 Apr 2018 11:04:42 -0500 Subject: [PATCH] validate: check rados config options Signed-off-by: Andrew Schoen --- plugins/actions/validate.py | 30 ++++++++++++++++++++++++++++-- roles/ceph-validate/tasks/main.yml | 11 +---------- 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/plugins/actions/validate.py b/plugins/actions/validate.py index bbba52c75..814785230 100644 --- a/plugins/actions/validate.py +++ b/plugins/actions/validate.py @@ -22,8 +22,6 @@ class ActionModule(ActionBase): host = host_vars['ansible_hostname'] mode = self._task.args.get('mode', 'permissive') - print host_vars['groups'] - self._supports_check_mode = False # XXX ? self._supports_async = True @@ -31,6 +29,7 @@ class ActionModule(ActionBase): result['_ansible_verbose_always'] = True try: + notario_store["groups"] = host_vars["groups"] notario.validate(host_vars, install_options, defined_keys=True) if host_vars["ceph_origin"] == "repository": @@ -53,6 +52,13 @@ class ActionModule(ActionBase): notario.validate(host_vars, monitor_options, defined_keys=True) + notario_store["radosgw_address"] = host_vars.get("radosgw_address", None) + notario_store["radosgw_address_block"] = host_vars.get("radosgw_address_block", None) + notario_store["radosgw_interface"] = host_vars.get("radosgw_interface", None) + + if host_vars["rgw_group_name"] in host_vars["groups"]: + notario.validate(host_vars, rados_options, defined_keys=True) + # validate osd scenario setup notario.validate(host_vars, osd_options, defined_keys=True) notario_store['osd_objectstore'] = host_vars["osd_objectstore"] @@ -128,6 +134,20 @@ def validate_ceph_stable_release(value): assert value in ['jewel', 'kraken', 'luminous', 'mimic'], "ceph_stable_release must be set to 'jewel', 'kraken', 'lumious' or 'mimic'" +def validate_rados_options(value): + """ + Either radosgw_interface, radosgw_address or radosgw_address_block must + be defined. + """ + radosgw_address_given = notario_store["radosgw_address"] != "address" + radosgw_address_block_given = notario_store["radosgw_address_block"] != "subnet" + radosgw_interface_given = notario_store["radosgw_interface"] != "interface" + + msg = "Either radosgw_address, radosgw_address_block or radosgw_interface must be provided" + + assert any([radosgw_address_given, radosgw_address_block_given, radosgw_interface_given]), msg + + install_options = ( ("ceph_origin", ceph_origin_choices), ('osd_objectstore', osd_objectstore_choices), @@ -161,6 +181,12 @@ monitor_options = ( ("public_network", types.string), ) +rados_options = ( + ("radosgw_address", validate_rados_options), + ("radosgw_address_block", validate_rados_options), + ("radosgw_interface", validate_rados_options), +) + osd_options = ( (optional("dmcrypt"), types.boolean), ("osd_scenario", validate_osd_scenarios), diff --git a/roles/ceph-validate/tasks/main.yml b/roles/ceph-validate/tasks/main.yml index c13d99493..7878d2f7a 100644 --- a/roles/ceph-validate/tasks/main.yml +++ b/roles/ceph-validate/tasks/main.yml @@ -2,7 +2,7 @@ - name: validate provided configuration validate: - mode: permissive + mode: strict - name: fail if local scenario is enabled on debian fail: @@ -56,12 +56,3 @@ - osd_group_name in group_names - osd_objectstore == 'bluestore' - ceph_release_num[ceph_release] < ceph_release_num.luminous - -- name: make sure radosgw_interface, radosgw_address or radosgw_address_block is defined - fail: - msg: "you must set radosgw_interface, radosgw_address or radosgw_address_block" - when: - - rgw_group_name in group_names - - radosgw_interface == 'interface' - - radosgw_address == 'address' - - radosgw_address_block == 'subnet' -- 2.39.5