Skip to content

Commit 915b33c

Browse files
committed
Handle radosgw hosts placement with non-default cluster name
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 <[email protected]>
1 parent 912de5a commit 915b33c

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

infrastructure-playbooks/cephadm-adopt.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -942,6 +942,7 @@
942942
- name: Update the placement of radosgw hosts
943943
ceph_orch_apply:
944944
fsid: "{{ fsid }}"
945+
cluster: "{{ cluster }}"
945946
spec: |
946947
service_type: rgw
947948
service_id: {{ ansible_facts['hostname'] }}
@@ -1480,6 +1481,7 @@
14801481
- name: Update the placement of alertmanager hosts
14811482
ceph_orch_apply:
14821483
fsid: "{{ fsid }}"
1484+
cluster: "{{ cluster }}"
14831485
spec: |
14841486
service_type: alertmanager
14851487
service_id: "{{ ansible_facts['hostname'] }}"

library/ceph_orch_apply.py

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323

2424
from ansible.module_utils.basic import AnsibleModule # type: ignore
2525
try:
26-
from ansible.module_utils.ca_common import exit_module, build_base_cmd_orch # type: ignore
26+
from ansible.module_utils.ca_common import exit_module, build_base_cmd # type: ignore
2727
except ImportError:
28-
from module_utils.ca_common import exit_module, build_base_cmd_orch
28+
from module_utils.ca_common import exit_module, build_base_cmd
2929

3030

3131
ANSIBLE_METADATA = {
@@ -50,6 +50,10 @@
5050
description:
5151
- The Ceph container image to use.
5252
required: false
53+
cluster:
54+
description:
55+
- The Ceph cluster name. Defaults to ceph
56+
required: false
5357
spec:
5458
description:
5559
- The service spec to apply
@@ -81,8 +85,12 @@ def parse_spec(spec: str) -> Dict:
8185
def retrieve_current_spec(module: AnsibleModule, expected_spec: Dict) -> Dict:
8286
""" retrieve current config of the service """
8387
service: str = expected_spec["service_type"]
84-
cmd = build_base_cmd_orch(module)
85-
cmd.extend(['ls', service])
88+
cmd = build_base_cmd(module)
89+
if cluster != 'ceph':
90+
conf_path = f"/etc/ceph/{cluster}.conf"
91+
keyring_path = f"/etc/ceph/{cluster}.client.admin.keyring"
92+
cmd.extend(['--config', conf_path, '--keyring', keyring_path])
93+
cmd.extend(['ceph', 'orch', 'ls', service])
8694
if 'service_name' in expected_spec:
8795
cmd.extend([expected_spec["service_name"]])
8896
else:
@@ -98,8 +106,13 @@ def retrieve_current_spec(module: AnsibleModule, expected_spec: Dict) -> Dict:
98106

99107
def apply_spec(module: "AnsibleModule",
100108
data: str) -> Tuple[int, List[str], str, str]:
101-
cmd = build_base_cmd_orch(module)
102-
cmd.extend(['apply', '-i', '-'])
109+
cmd = build_base_cmd(module)
110+
cluster = module.params.get('cluster')
111+
if cluster != 'ceph':
112+
conf_path = f"/etc/ceph/{cluster}.conf"
113+
keyring_path = f"/etc/ceph/{cluster}.client.admin.keyring"
114+
cmd.extend(['--config', conf_path, '--keyring', keyring_path])
115+
cmd.extend(['ceph', 'orch', 'apply', '-i', '-'])
103116
rc, out, err = module.run_command(cmd, data=data)
104117

105118
if rc:
@@ -131,7 +144,9 @@ def run_module() -> None:
131144
docker=dict(type=bool,
132145
required=False,
133146
default=False),
134-
image=dict(type='str', required=False)
147+
image=dict(type='str', required=False),
148+
cluster=dict(type='str', required=False,
149+
default='ceph')
135150
)
136151

137152
module = AnsibleModule(

0 commit comments

Comments
 (0)