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

fix for #158. enable ec_profiles role to set the crush-failure-domain. #159

Merged
merged 1 commit into from
Jan 3, 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
21 changes: 20 additions & 1 deletion plugins/modules/cephadm_ec_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@
- Restrict placement to devices of a specific class (hdd/ssd)
required: false
type: str
crush_failure_domain:
description:
- Set the failure domain for the CRUSH rule (e.g., 'rack', 'host', 'osd')
required: false
type: str

author:
- Guillaume Abrioux <[email protected]>
Expand All @@ -94,6 +99,13 @@
cephadm_ec_profile:
name: foo
state: absent

- name: create an erasure code profile with custom failure domain
cephadm_ec_profile:
name: foo-osd
k: 4
m: 2
crush_failure_domain: osd
'''

from ansible.module_utils.basic import AnsibleModule
Expand All @@ -120,7 +132,7 @@ def get_profile(module, name):
return cmd


def create_profile(module, name, k, m, stripe_unit, crush_device_class, directory, plugin, force=False): # noqa: E501
def create_profile(module, name, k, m, stripe_unit, crush_device_class, crush_failure_domain, directory, plugin, force=False): # noqa: E501
'''
Create a profile
'''
Expand All @@ -130,6 +142,8 @@ def create_profile(module, name, k, m, stripe_unit, crush_device_class, director
args.append('stripe_unit={0}'.format(stripe_unit))
if crush_device_class:
args.append('crush-device-class={0}'.format(crush_device_class))
if crush_failure_domain:
args.append('crush-failure-domain={0}'.format(crush_failure_domain))
if directory:
args.append('directory={0}'.format(plugin))
if plugin:
Expand Down Expand Up @@ -165,6 +179,7 @@ def run_module():
k=dict(type='str', required=False),
m=dict(type='str', required=False),
crush_device_class=dict(type='str', required=False),
crush_failure_domain=dict(type='str', required=False),
directory=dict(type='str', required=False),
plugin=dict(type='str', required=False),
)
Expand All @@ -182,6 +197,7 @@ def run_module():
k = module.params.get('k')
m = module.params.get('m')
crush_device_class = module.params.get('crush_device_class')
crush_failure_domain = module.params.get('crush_failure_domain')
directory = module.params.get('directory')
plugin = module.params.get('plugin')

Expand Down Expand Up @@ -209,6 +225,7 @@ def run_module():
current_profile['m'] != m or \
current_profile.get('stripe_unit', stripe_unit) != stripe_unit or \
current_profile.get('crush-device-class', crush_device_class) != crush_device_class or \
current_profile.get('crush-failure-domain', crush_failure_domain) != crush_failure_domain or \
current_profile.get('directory', directory) != directory or \
current_profile.get('plugin', plugin) != plugin: # noqa: E501
rc, cmd, out, err = exec_command(module,
Expand All @@ -218,6 +235,7 @@ def run_module():
m,
stripe_unit,
crush_device_class, # noqa: E501
crush_failure_domain,
directory,
plugin,
force=True)) # noqa: E501
Expand All @@ -230,6 +248,7 @@ def run_module():
m,
stripe_unit, # noqa: E501
crush_device_class, # noqa: E501
crush_failure_domain,
directory,
plugin))
if rc == 0:
Expand Down
4 changes: 4 additions & 0 deletions roles/ec_profiles/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ This role assumes the existence of the following groups:
m: 2
- name: delete_me
state: absent
- name: foo-osd
k: 4
m: 2
crush_failure_domain: osd

```

Expand Down
1 change: 1 addition & 0 deletions roles/ec_profiles/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
directory: "{{ item.directory | default(omit) }}"
crush_root: "{{ item.crush_root | default(omit) }}"
crush_device_class: "{{ item.crush_device_class | default(omit) }}"
crush_failure_domain: "{{ item.crush_failure_domain | default(omit) }}"
with_items: "{{ cephadm_ec_profiles }}"
delegate_to: "{{ groups['mons'][0] }}"
run_once: true