diff --git a/group_vars/clients.yml.sample b/group_vars/clients.yml.sample index 40bf811ac..aa41c1cf0 100644 --- a/group_vars/clients.yml.sample +++ b/group_vars/clients.yml.sample @@ -14,9 +14,25 @@ dummy: #copy_admin_key: false #user_config: false +#test: +# name: "test" +# pg_num: "{{ hostvars[groups[mon_group_name][0]]['osd_pool_default_pg_num'] }}" +# pgp_num: "{{ hostvars[groups[mon_group_name][0]]['osd_pool_default_pg_num'] }}" +# rule_name: "replicated_rule" +# type: "replicated" +# erasure_profile: "" +# size: "" +#test2: +# name: "test2" +# pg_num: "{{ hostvars[groups[mon_group_name][0]]['osd_pool_default_pg_num'] }}" +# pgp_num: "{{ hostvars[groups[mon_group_name][0]]['osd_pool_default_pg_num'] }}" +# rule_name: "replicated_rule" +# type: "replicated" +# erasure_profile: "" +# size: "" #pools: -# - { name: test, pgs: "{{ hostvars[groups[mon_group_name][0]]['osd_pool_default_pg_num'] }}" } -# - { name: test2, pgs: "{{ hostvars[groups[mon_group_name][0]]['osd_pool_default_pg_num'] }}" } +# - "{{ test }}" +# - "{{ test2 }}" # Can add `mds_cap` attribute to override the default value which is '' for mds capabilities. # To have have ansible setfacl the generated key for $user, set the acls var like so: diff --git a/roles/ceph-client/defaults/main.yml b/roles/ceph-client/defaults/main.yml index 0c538e514..e588e2cad 100644 --- a/roles/ceph-client/defaults/main.yml +++ b/roles/ceph-client/defaults/main.yml @@ -6,9 +6,25 @@ copy_admin_key: false user_config: false +test: + name: "test" + pg_num: "{{ hostvars[groups[mon_group_name][0]]['osd_pool_default_pg_num'] }}" + pgp_num: "{{ hostvars[groups[mon_group_name][0]]['osd_pool_default_pg_num'] }}" + rule_name: "replicated_rule" + type: "replicated" + erasure_profile: "" + size: "" +test2: + name: "test2" + pg_num: "{{ hostvars[groups[mon_group_name][0]]['osd_pool_default_pg_num'] }}" + pgp_num: "{{ hostvars[groups[mon_group_name][0]]['osd_pool_default_pg_num'] }}" + rule_name: "replicated_rule" + type: "replicated" + erasure_profile: "" + size: "" pools: - - { name: test, pgs: "{{ hostvars[groups[mon_group_name][0]]['osd_pool_default_pg_num'] }}" } - - { name: test2, pgs: "{{ hostvars[groups[mon_group_name][0]]['osd_pool_default_pg_num'] }}" } + - "{{ test }}" + - "{{ test2 }}" # Can add `mds_cap` attribute to override the default value which is '' for mds capabilities. # To have have ansible setfacl the generated key for $user, set the acls var like so: diff --git a/roles/ceph-client/tasks/create_users_keys.yml b/roles/ceph-client/tasks/create_users_keys.yml index 5fa4fe94f..be3946226 100644 --- a/roles/ceph-client/tasks/create_users_keys.yml +++ b/roles/ceph-client/tasks/create_users_keys.yml @@ -45,11 +45,20 @@ when: - copy_admin_key -- name: create pools - command: "{{ docker_exec_client_cmd }} --cluster {{ cluster }} osd pool create {{ item.name }} {{ item.get('pgs', hostvars[groups[mon_group_name][0]]['osd_pool_default_pg_num']) }}" +- name: create pool(s) + command: > + {{ docker_exec_client_cmd }} --cluster {{ cluster }} + osd pool create {{ item.name }} + {{ item.get('pg_num', hostvars[groups[mon_group_name][0]]['osd_pool_default_pg_num']) }} + {{ item.pgp_num | default(item.pg_num) }} + {{ item.rule_name | default("replicated_rule") }} + {{ item.type | default("replicated") }} + {%- if item.type | default("replicated") == 'erasure' and item.erasure_profile != '' %} + {{ item.erasure_profile }} + {%- endif %} + {{ item.size | default('') }} with_items: "{{ pools }}" changed_when: false - failed_when: false when: - pools | length > 0 - copy_admin_key diff --git a/tests/functional/centos/7/cluster/group_vars/all b/tests/functional/centos/7/cluster/group_vars/all index 48c814b62..925155a35 100644 --- a/tests/functional/centos/7/cluster/group_vars/all +++ b/tests/functional/centos/7/cluster/group_vars/all @@ -18,6 +18,25 @@ osd_scenario: non-collocated os_tuning_params: - { name: fs.file-max, value: 26234859 } user_config: True +test: + name: "test" + pg_num: "{{ hostvars[groups[mon_group_name][0]]['osd_pool_default_pg_num'] }}" + pgp_num: "{{ hostvars[groups[mon_group_name][0]]['osd_pool_default_pg_num'] }}" + rule_name: "HDD" + type: "replicated" + erasure_profile: "" + size: "" +test2: + name: "test2" + pg_num: "{{ hostvars[groups[mon_group_name][0]]['osd_pool_default_pg_num'] }}" + pgp_num: "{{ hostvars[groups[mon_group_name][0]]['osd_pool_default_pg_num'] }}" + rule_name: "HDD" + type: "replicated" + erasure_profile: "" + size: "" +pools: + - "{{ test }}" + - "{{ test2 }}" ceph_conf_overrides: global: osd_pool_default_size: 1 diff --git a/tests/functional/centos/7/docker-collocation/group_vars/all b/tests/functional/centos/7/docker-collocation/group_vars/all index 42df7b7fb..fb286460c 100644 --- a/tests/functional/centos/7/docker-collocation/group_vars/all +++ b/tests/functional/centos/7/docker-collocation/group_vars/all @@ -28,6 +28,22 @@ ceph_conf_overrides: osd_pool_default_pg_num: 8 osd_pool_default_size: 1 user_config: True -keys: - - { name: client.test, key: "AQAin8tUoMPDGRAACcfAQHbq4eTuUoTCZdW1Uw==", mon_cap: "allow r", osd_cap: "allow class-read object_prefix rbd_children, allow rwx pool=test", mode: "0600", acls: [] } - - { name: client.test2, key: "AQAin8tUAJkGGhAA8WZ8Lz5c7IkT8QZ5s7bI1A==", mon_cap: "allow r", osd_cap: "allow class-read object_prefix rbd_children, allow rwx pool=test2", mode: "0600", acls: [] } +test: + name: "test" + pg_num: "{{ hostvars[groups[mon_group_name][0]]['osd_pool_default_pg_num'] }}" + pgp_num: "{{ hostvars[groups[mon_group_name][0]]['osd_pool_default_pg_num'] }}" + rule_name: "HDD" + type: "replicated" + erasure_profile: "" + size: "" +test2: + name: "test2" + pg_num: "{{ hostvars[groups[mon_group_name][0]]['osd_pool_default_pg_num'] }}" + pgp_num: "{{ hostvars[groups[mon_group_name][0]]['osd_pool_default_pg_num'] }}" + rule_name: "HDD" + type: "replicated" + erasure_profile: "" + size: "" +pools: + - "{{ test }}" + - "{{ test2 }}" diff --git a/tests/functional/centos/7/docker/group_vars/all b/tests/functional/centos/7/docker/group_vars/all index 9575fa435..fc8f6bece 100644 --- a/tests/functional/centos/7/docker/group_vars/all +++ b/tests/functional/centos/7/docker/group_vars/all @@ -27,6 +27,22 @@ ceph_conf_overrides: global: osd_pool_default_size: 1 user_config: True -keys: - - { name: client.test, key: "AQAin8tUoMPDGRAACcfAQHbq4eTuUoTCZdW1Uw==", mon_cap: "allow r", osd_cap: "allow class-read object_prefix rbd_children, allow rwx pool=test", mode: "0600", acls: [] } - - { name: client.test2, key: "AQAin8tUAJkGGhAA8WZ8Lz5c7IkT8QZ5s7bI1A==", mon_cap: "allow r", osd_cap: "allow class-read object_prefix rbd_children, allow rwx pool=test2", mode: "0600", acls: [] } +test: + name: "test" + pg_num: "{{ hostvars[groups[mon_group_name][0]]['osd_pool_default_pg_num'] }}" + pgp_num: "{{ hostvars[groups[mon_group_name][0]]['osd_pool_default_pg_num'] }}" + rule_name: "HDD" + type: "replicated" + erasure_profile: "" + size: "" +test2: + name: "test2" + pg_num: "{{ hostvars[groups[mon_group_name][0]]['osd_pool_default_pg_num'] }}" + pgp_num: "{{ hostvars[groups[mon_group_name][0]]['osd_pool_default_pg_num'] }}" + rule_name: "HDD" + type: "replicated" + erasure_profile: "" + size: "" +pools: + - "{{ test }}" + - "{{ test2 }}"