Skip to content

Commit

Permalink
Merge pull request #86 from stackhpc/ec_plugins
Browse files Browse the repository at this point in the history
Add support for choosing plugin in EC profiles
  • Loading branch information
cityofships authored Feb 28, 2023
2 parents 1767d94 + 64c0750 commit 825c64e
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 10 deletions.
2 changes: 1 addition & 1 deletion galaxy.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace: "stackhpc"
name: "cephadm"
version: "1.12.2"
version: "1.13.0"
readme: "README.md"
authors:
- "Michal Nasiadka"
Expand Down
32 changes: 28 additions & 4 deletions plugins/modules/cephadm_ec_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@
- Compute coding chunks for each object and store them on different
OSDs.
required: false
plugin:
description:
- Use the erasure code plugin to compute coding chunks and recover
missing chunks.
required: false
directory:
description:
- Set the directory name from which the erasure code plugin is
loaded.
required: false
crush_root:
description:
- The name of the crush bucket used for the first step of the CRUSH
Expand All @@ -84,7 +94,7 @@
k: 4
m: 2
- name: delete an erassure code profile
- name: delete an erasure code profile
cephadm_ec_profile:
name: foo
state: absent
Expand All @@ -106,7 +116,7 @@ def get_profile(module, name):
return cmd


def create_profile(module, name, k, m, stripe_unit, crush_device_class, force=False): # noqa: E501
def create_profile(module, name, k, m, stripe_unit, crush_device_class, directory, plugin, force=False): # noqa: E501
'''
Create a profile
'''
Expand All @@ -116,6 +126,10 @@ def create_profile(module, name, k, m, stripe_unit, crush_device_class, force=Fa
args.append('stripe_unit={}'.format(stripe_unit))
if crush_device_class:
args.append('crush-device-class={}'.format(crush_device_class))
if directory:
args.append('directory={}'.format(plugin))
if plugin:
args.append('plugin={}'.format(plugin))
if force:
args.append('--force')

Expand Down Expand Up @@ -147,6 +161,8 @@ def run_module():
k=dict(type='str', required=False),
m=dict(type='str', required=False),
crush_device_class=dict(type='str', required=False, default=''),
directory=dict(type='str', required=False),
plugin=dict(type='str', required=False),
)

module = AnsibleModule(
Expand All @@ -162,6 +178,8 @@ def run_module():
k = module.params.get('k')
m = module.params.get('m')
crush_device_class = module.params.get('crush_device_class')
directory = module.params.get('directory')
plugin = module.params.get('plugin')

if module.check_mode:
module.exit_json(
Expand All @@ -186,14 +204,18 @@ def run_module():
if current_profile['k'] != k or \
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: # noqa: E501
current_profile.get('crush-device-class', crush_device_class) != crush_device_class or \
current_profile.get('directory', directory) != directory or \
current_profile.get('plugin', plugin) != plugin: # noqa: E501
rc, cmd, out, err = exec_command(module,
create_profile(module,
name,
k,
m,
stripe_unit,
crush_device_class, # noqa: E501
directory,
plugin,
force=True)) # noqa: E501
changed = True
else:
Expand All @@ -203,7 +225,9 @@ def run_module():
k,
m,
stripe_unit, # noqa: E501
crush_device_class)) # noqa: E501
crush_device_class, # noqa: E501
directory,
plugin))
if rc == 0:
changed = True

Expand Down
14 changes: 9 additions & 5 deletions roles/ec_profiles/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ This role creates/deletes Ceph EC profiles.

### Host prerequisites

* The role assumes target hosts connection over SSH with user that has passwordless sudo configured.
* Either direct Internet access or private registry with desired Ceph image accessible to all hosts is required.
* The role assumes target host connection over SSH to the first MON server.

### Inventory

Expand All @@ -17,11 +16,16 @@ This role assumes the existence of the following groups:

## Role variables

* `cephadm_ec_profiles`: A list of pools to define
* `cephadm_ec_profiles`: A list of pools to manage.
Example:
```
cephadm_ec_profiles:
```
- name: foo
k: 4
m: 2
- name: delete_me
state: absent
Check the `cephadm_ec_profile` module docs for supported key options.
```

Check Erasure Code profiles [docs](https://docs.ceph.com/en/pacific/rados/operations/erasure-code-profile/#osd-erasure-code-profile-set) for supported key options.
2 changes: 2 additions & 0 deletions roles/ec_profiles/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
stripe_unit: "{{ item.stripe_unit | default(omit) }}"
k: "{{ item.k }}"
m: "{{ item.m }}"
plugin: "{{ item.plugin | default(omit) }}"
directory: "{{ item.directory | default(omit) }}"
crush_root: "{{ item.crush_root | default(omit) }}"
crush_device_class: "{{ item.crush_device_class | default(omit) }}"
with_items: "{{ cephadm_ec_profiles }}"
Expand Down

0 comments on commit 825c64e

Please sign in to comment.