From 2cf06b515f3e173aa3720cf28e4149149d881941 Mon Sep 17 00:00:00 2001 From: Guillaume Abrioux Date: Fri, 1 Jun 2018 17:33:54 +0200 Subject: [PATCH] rgw: refact rgw pools creation Refact of 8704144e3157aa253fb7563fe701d9d434bf2f3e There is no need to have duplicated tasks for this. The rgw pools creation should be delegated on a monitor node se we don't have to care if the admin keyring is present on rgw node. By the way, only one task is needed to create the pools, we just need to use the `docker_exec_cmd` fact already defined in `ceph-defaults` to achieve it. Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1550281 Signed-off-by: Guillaume Abrioux --- roles/ceph-rgw/tasks/docker/main.yml | 5 ---- roles/ceph-rgw/tasks/docker/rgw_pool_pgs.yml | 26 ------------------- roles/ceph-rgw/tasks/main.yml | 22 +++++++--------- roles/ceph-rgw/tasks/rgw_pool_pgs.yml | 24 ----------------- .../7/docker-collocation/group_vars/rgws | 2 +- .../functional/centos/7/ooo-collocation/hosts | 5 ++++ 6 files changed, 15 insertions(+), 69 deletions(-) delete mode 100644 roles/ceph-rgw/tasks/docker/rgw_pool_pgs.yml delete mode 100644 roles/ceph-rgw/tasks/rgw_pool_pgs.yml diff --git a/roles/ceph-rgw/tasks/docker/main.yml b/roles/ceph-rgw/tasks/docker/main.yml index 23daceade..4850e4b7c 100644 --- a/roles/ceph-rgw/tasks/docker/main.yml +++ b/roles/ceph-rgw/tasks/docker/main.yml @@ -6,8 +6,3 @@ - name: include start_docker_rgw.yml include: start_docker_rgw.yml - -- name: include rgw_pool_pgs.yml - include: rgw_pool_pgs.yml - when: - - rgw_create_pools is defined diff --git a/roles/ceph-rgw/tasks/docker/rgw_pool_pgs.yml b/roles/ceph-rgw/tasks/docker/rgw_pool_pgs.yml deleted file mode 100644 index d2e8feed0..000000000 --- a/roles/ceph-rgw/tasks/docker/rgw_pool_pgs.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -# If admin key has been copied to the RGWs, we can run the command from them. -- name: create rgw pools if rgw_create_pools is defined - command: "{{ docker_exec_cmd }} ceph --connect-timeout 5 --cluster {{ cluster }} osd pool create {{ item.key }} {{ item.value.pg_num }}" - changed_when: false - run_once: true - with_dict: "{{ rgw_create_pools }}" - when: - - copy_admin_key - -# If no admin key has been copied to the RGWs, we have to run the command from the first monitor. -- name: set_fact docker_exec_mon_cmd - set_fact: - docker_exec_mon_cmd: "docker exec ceph-mon-{{ hostvars[groups.get(mon_group_name)[0]]['ansible_hostname'] }}" - when: - - not copy_admin_key - -# If no admin key has been copied to the RGWs, we have to run the command from the first monitor. -- name: create rgw pools if rgw_create_pools is defined, delegated to first monitor - command: "{{ docker_exec_mon_cmd }} ceph --connect-timeout 5 --cluster {{ cluster }} osd pool create {{ item.key }} {{ item.value.pg_num }}" - changed_when: false - run_once: true - delegate_to: "{{ groups[mon_group_name][0] }}" - with_dict: "{{ rgw_create_pools }}" - when: - - not copy_admin_key diff --git a/roles/ceph-rgw/tasks/main.yml b/roles/ceph-rgw/tasks/main.yml index 85a3400b0..5641407ba 100644 --- a/roles/ceph-rgw/tasks/main.yml +++ b/roles/ceph-rgw/tasks/main.yml @@ -1,10 +1,4 @@ --- -- name: set_fact docker_exec_cmd - set_fact: - docker_exec_cmd: "docker exec ceph-rgw-{{ ansible_hostname }}" - when: - - containerized_deployment - - name: include common.yml include: common.yml @@ -29,13 +23,6 @@ # Hard code this so we will skip the entire file instead of individual tasks (Default isn't Consistent) static: False -- name: include rgw_pool_pgs.yml - include: rgw_pool_pgs.yml - when: - - rgw_create_pools is defined - - not containerized_deployment - static: False - - name: include multisite/main.yml include: multisite/main.yml when: @@ -51,3 +38,12 @@ - containerized_deployment # Hard code this so we will skip the entire file instead of individual tasks (Default isn't Consistent) static: False + +- name: create rgw pools if rgw_create_pools is defined + command: "{{ docker_exec_cmd }} ceph --connect-timeout 5 --cluster {{ cluster }} osd pool create {{ item.key }} {{ item.value.pg_num }}" + changed_when: false + with_dict: "{{ rgw_create_pools }}" + delegate_to: "{{ groups[mon_group_name][0] }}" + run_once: true + when: + - rgw_create_pools is defined diff --git a/roles/ceph-rgw/tasks/rgw_pool_pgs.yml b/roles/ceph-rgw/tasks/rgw_pool_pgs.yml deleted file mode 100644 index 41074b67f..000000000 --- a/roles/ceph-rgw/tasks/rgw_pool_pgs.yml +++ /dev/null @@ -1,24 +0,0 @@ ---- -- name: create rgw pools if rgw_create_pools is defined - command: ceph --connect-timeout 5 --cluster {{ cluster }} osd pool create {{ item.key }} {{ item.value.pg_num }} - changed_when: false - run_once: true - with_dict: "{{ rgw_create_pools }}" - when: - - not containerized_deployment - -# On first monitor. -- name: set_fact docker_exec_rgw_cmd - set_fact: - docker_exec_rgw_cmd: "docker exec ceph-mon-{{ hostvars[groups.get(mon_group_name)[0]]['ansible_hostname'] }}" - when: - - containerized_deployment - -- name: create rgw pools if rgw_create_pools is defined - command: "{{ docker_exec_rgw_cmd }} ceph --connect-timeout 5 --cluster {{ cluster }} osd pool create {{ item.key }} {{ item.value.pg_num }}" - changed_when: false - run_once: true - with_dict: "{{ rgw_create_pools }}" - delegate_to: "{{ groups[mon_group_name][0] }}" - when: - - containerized_deployment diff --git a/tests/functional/centos/7/docker-collocation/group_vars/rgws b/tests/functional/centos/7/docker-collocation/group_vars/rgws index 53dd034b1..265d18208 100644 --- a/tests/functional/centos/7/docker-collocation/group_vars/rgws +++ b/tests/functional/centos/7/docker-collocation/group_vars/rgws @@ -3,4 +3,4 @@ rgw_create_pools: foo: pg_num: 17 bar: - pg_num: 19 + pg_num: 19 \ No newline at end of file diff --git a/tests/functional/centos/7/ooo-collocation/hosts b/tests/functional/centos/7/ooo-collocation/hosts index afffc3746..b1271e1b7 100644 --- a/tests/functional/centos/7/ooo-collocation/hosts +++ b/tests/functional/centos/7/ooo-collocation/hosts @@ -67,6 +67,11 @@ all: radosgw_keystone_ssl: false user_config: true copy_admin_key: true + rgw_create_pools: + foo: + pg_num: 17 + bar: + pg_num: 19 clients: hosts: client0: {}