]> git.apps.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
validate: check rados config options
authorAndrew Schoen <aschoen@redhat.com>
Mon, 30 Apr 2018 16:04:42 +0000 (11:04 -0500)
committerGuillaume Abrioux <gabrioux@redhat.com>
Fri, 18 May 2018 15:58:24 +0000 (17:58 +0200)
Signed-off-by: Andrew Schoen <aschoen@redhat.com>
plugins/actions/validate.py
roles/ceph-validate/tasks/main.yml

index bbba52c75dbe2f94821165bf68cfa7c0549032c8..814785230994e9fd5e00f4be819f16b23115c503 100644 (file)
@@ -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),
index c13d99493481e62219c460798e2e17f52ce341ec..7878d2f7a16dad51dee458923475a9cb243543ce 100644 (file)
@@ -2,7 +2,7 @@
 
 - name: validate provided configuration
   validate:
-    mode: permissive
+    mode: strict
 
 - name: fail if local scenario is enabled on debian
   fail:
     - 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'