]> git.apps.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
Handle radosgw hosts placement with non-default cluster name
authorJohn Fulton <fulton@redhat.com>
Thu, 16 Jan 2025 21:30:20 +0000 (16:30 -0500)
committerTeoman ONAY <tonay@ibm.com>
Tue, 11 Feb 2025 12:16:02 +0000 (13:16 +0100)
In cephadm-adopt.yml TASK "Update the placement of radosgw hosts"
does not handle when Ansible var cluster is something other than
"ceph", unless this patch is used.

Update module ceph_orch_apply to support optional cluster
parameter using the same style as in module ceph_config.
The command is only extended to inclue the new keyring
and config options if cluster name is not ceph.

This patch is necessary to migrate older clusters which were
deployed when custom names were supported.

Closes: https://issues.redhat.com/browse/RHCEPH-10442
Signed-off-by: John Fulton <fulton@redhat.com>
(cherry picked from commit 8b2f2133fab63950c92daa06851ef2d8680a3007)

infrastructure-playbooks/cephadm-adopt.yml
library/ceph_orch_apply.py

index 7eec403952a0e327a0887fff87807d4f5f6acbfc..25cc2000e89b344cab066c8132f6d3f12699b654 100644 (file)
     - name: Update the placement of radosgw hosts
       ceph_orch_apply:
         fsid: "{{ fsid }}"
+        cluster: "{{ cluster }}"
         spec: |
           service_type: rgw
           service_id: {{ ansible_facts['hostname'] }}
         - name: Update the placement of alertmanager hosts
           ceph_orch_apply:
             fsid: "{{ fsid }}"
+            cluster: "{{ cluster }}"
             spec: |
               service_type: alertmanager
               service_id: "{{ ansible_facts['hostname'] }}"
         - name: Update the placement of prometheus hosts
           ceph_orch_apply:
             fsid: "{{ fsid }}"
+            cluster: "{{ cluster }}"
             spec: |
               service_name: prometheus
               service_id: "{{ ansible_facts['hostname'] }}"
index 1df457b09f91a2921118e5ea9a82e9dbc07377cf..d5b1b32c941b8cf3e37f986cd8b33c5726b90377 100644 (file)
@@ -23,9 +23,9 @@ import yaml
 
 from ansible.module_utils.basic import AnsibleModule  # type: ignore
 try:
-    from ansible.module_utils.ca_common import exit_module, build_base_cmd_orch  # type: ignore
+    from ansible.module_utils.ca_common import exit_module, build_base_cmd  # type: ignore
 except ImportError:
-    from module_utils.ca_common import exit_module, build_base_cmd_orch
+    from module_utils.ca_common import exit_module, build_base_cmd
 
 
 ANSIBLE_METADATA = {
@@ -50,6 +50,10 @@ options:
         description:
             - The Ceph container image to use.
         required: false
+    cluster:
+        description:
+            - The Ceph cluster name. Defaults to ceph
+        required: false
     spec:
         description:
             - The service spec to apply
@@ -81,8 +85,13 @@ def parse_spec(spec: str) -> Dict:
 def retrieve_current_spec(module: AnsibleModule, expected_spec: Dict) -> Dict:
     """ retrieve current config of the service """
     service: str = expected_spec["service_type"]
-    cmd = build_base_cmd_orch(module)
-    cmd.extend(['ls', service])
+    cmd = build_base_cmd(module)
+    cluster = module.params.get('cluster')
+    if cluster != 'ceph':
+        conf_path = f"/etc/ceph/{cluster}.conf"
+        keyring_path = f"/etc/ceph/{cluster}.client.admin.keyring"
+        cmd.extend(['--config', conf_path, '--keyring', keyring_path])
+    cmd.extend(['ceph', 'orch', 'ls', service])
     if 'service_name' in expected_spec:
         cmd.extend([expected_spec["service_name"]])
     else:
@@ -98,8 +107,13 @@ def retrieve_current_spec(module: AnsibleModule, expected_spec: Dict) -> Dict:
 
 def apply_spec(module: "AnsibleModule",
                data: str) -> Tuple[int, List[str], str, str]:
-    cmd = build_base_cmd_orch(module)
-    cmd.extend(['apply', '-i', '-'])
+    cmd = build_base_cmd(module)
+    cluster = module.params.get('cluster')
+    if cluster != 'ceph':
+        conf_path = f"/etc/ceph/{cluster}.conf"
+        keyring_path = f"/etc/ceph/{cluster}.client.admin.keyring"
+        cmd.extend(['--config', conf_path, '--keyring', keyring_path])
+    cmd.extend(['ceph', 'orch', 'apply', '-i', '-'])
     rc, out, err = module.run_command(cmd, data=data)
 
     if rc:
@@ -131,7 +145,9 @@ def run_module() -> None:
         docker=dict(type=bool,
                     required=False,
                     default=False),
-        image=dict(type='str', required=False)
+        image=dict(type='str', required=False),
+        cluster=dict(type='str', required=False,
+                     default='ceph')
     )
 
     module = AnsibleModule(