Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle RGW hosts placement during adoption of older clusters with multiple subnets #7633

Merged
merged 2 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion infrastructure-playbooks/cephadm-adopt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -942,6 +942,7 @@
- name: Update the placement of radosgw hosts
ceph_orch_apply:
fsid: "{{ fsid }}"
cluster: "{{ cluster }}"
spec: |
service_type: rgw
service_id: {{ ansible_facts['hostname'] }}
Expand All @@ -950,7 +951,7 @@
hosts:
- {{ ansible_facts['nodename'] }}
{% if rgw_subnet is defined %}
networks: "{{ radosgw_address_block }}"
networks: {{ radosgw_address_block.split(',') | list if ',' in radosgw_address_block else radosgw_address_block | string }}
{% endif %}
spec:
rgw_frontend_port: {{ radosgw_frontend_port }}
Expand Down Expand Up @@ -1480,6 +1481,7 @@
- name: Update the placement of alertmanager hosts
ceph_orch_apply:
fsid: "{{ fsid }}"
cluster: "{{ cluster }}"
spec: |
service_type: alertmanager
service_id: "{{ ansible_facts['hostname'] }}"
Expand All @@ -1503,6 +1505,7 @@
- name: Update the placement of prometheus hosts
ceph_orch_apply:
fsid: "{{ fsid }}"
cluster: "{{ cluster }}"
spec: |
service_name: prometheus
service_id: "{{ ansible_facts['hostname'] }}"
Expand Down
30 changes: 23 additions & 7 deletions library/ceph_orch_apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@

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 = {
Expand All @@ -50,6 +50,10 @@
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
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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(
Expand Down