From b325cc386ee49afccda6220341591eb73fa4bb7f Mon Sep 17 00:00:00 2001 From: Guillaume Abrioux Date: Mon, 7 Oct 2019 11:08:44 +0200 Subject: [PATCH] switch_to_containers: do not re-set `ceph_uid` This commit refacts the way we set `ceph_uid` fact in `ceph-facts` and removes all `set_fact` tasks for `ceph_uid` in switch-to-containers playbook to avoid duplicated code. Signed-off-by: Guillaume Abrioux (cherry picked from commit fa9b42e98e32d2b3eff9605db044e37421d8b938) --- ...inerized-to-containerized-ceph-daemons.yml | 124 ++++-------------- roles/ceph-facts/tasks/facts.yml | 12 +- 2 files changed, 30 insertions(+), 106 deletions(-) diff --git a/infrastructure-playbooks/switch-from-non-containerized-to-containerized-ceph-daemons.yml b/infrastructure-playbooks/switch-from-non-containerized-to-containerized-ceph-daemons.yml index 62bdcfac0..a52ee2394 100644 --- a/infrastructure-playbooks/switch-from-non-containerized-to-containerized-ceph-daemons.yml +++ b/infrastructure-playbooks/switch-from-non-containerized-to-containerized-ceph-daemons.yml @@ -75,20 +75,11 @@ - ceph-mon@.service - ceph-mon.target - - name: set_fact ceph_uid for ubuntu - set_fact: - ceph_uid: 64045 - when: ceph_docker_image_tag | string is search("ubuntu") - - - name: set_fact ceph_uid for red hat - set_fact: - ceph_uid: 167 - when: ceph_docker_image_tag | string is match("latest") or ceph_docker_image_tag | string is search("centos") or ceph_docker_image_tag | string is search("fedora") + - import_role: + name: ceph-defaults - - name: set_fact ceph_uid for rhel - set_fact: - ceph_uid: 167 - when: ceph_docker_image is search("rhceph") + - import_role: + name: ceph-facts # NOTE: changed from file module to raw find command for performance reasons # The file module has to run checks on current ownership of all directories and files. This is unnecessary @@ -117,12 +108,6 @@ failed_when: false tasks: - - import_role: - name: ceph-defaults - - - import_role: - name: ceph-facts - - import_role: name: ceph-handler @@ -173,13 +158,11 @@ - ceph-mgr@.service - ceph-mgr.target - - set_fact: - ceph_uid: 64045 - when: ceph_docker_image_tag | string is match("latest") or ceph_docker_image_tag | string is search("ubuntu") + - import_role: + name: ceph-defaults - - set_fact: - ceph_uid: 167 - when: ceph_docker_image_tag | string is search("centos") or ceph_docker_image is search("rhceph") or ceph_docker_image_tag | string is search("fedora") + - import_role: + name: ceph-facts # NOTE: changed from file module to raw find command for performance reasons # The file module has to run checks on current ownership of all directories and files. This is unnecessary @@ -189,12 +172,6 @@ changed_when: false tasks: - - import_role: - name: ceph-defaults - - - import_role: - name: ceph-facts - - import_role: name: ceph-handler @@ -249,19 +226,8 @@ - /usr/lib/systemd/system/ceph-osd@.service - /usr/lib/systemd/system/ceph-volume@.service - - set_fact: - ceph_uid: 64045 - when: ceph_docker_image_tag | string is match("latest") or ceph_docker_image_tag | string is search("ubuntu") - - - name: set_fact ceph_uid for red hat - set_fact: - ceph_uid: 167 - when: ceph_docker_image_tag | string is match("latest") or ceph_docker_image_tag | string is search("centos") or ceph_docker_image_tag | string is search("fedora") - - - name: set_fact ceph_uid for rhel - set_fact: - ceph_uid: 167 - when: ceph_docker_image is search("rhceph") + - import_role: + name: ceph-facts # NOTE: changed from file module to raw find command for performance reasons # The file module has to run checks on current ownership of all directories and files. This is unnecessary @@ -304,12 +270,6 @@ when: osd_running.rc != 0 tasks: - - import_role: - name: ceph-defaults - - - import_role: - name: ceph-facts - - import_role: name: ceph-handler @@ -369,13 +329,11 @@ - ceph-mds@.service - ceph-mds.target - - set_fact: - ceph_uid: 64045 - when: ceph_docker_image_tag | string is match("latest") or ceph_docker_image_tag | string is search("ubuntu") + - import_role: + name: ceph-defaults - - set_fact: - ceph_uid: 167 - when: ceph_docker_image_tag | string is search("centos") or ceph_docker_image is search("rhceph") or ceph_docker_image_tag | string is search("fedora") + - import_role: + name: ceph-facts # NOTE: changed from file module to raw find command for performance reasons # The file module has to run checks on current ownership of all directories and files. This is unnecessary @@ -385,12 +343,6 @@ changed_when: false tasks: - - import_role: - name: ceph-defaults - - - import_role: - name: ceph-facts - - import_role: name: ceph-handler @@ -415,13 +367,11 @@ serial: 1 become: true pre_tasks: - - set_fact: - ceph_uid: 64045 - when: ceph_docker_image_tag | string is match("latest") or ceph_docker_image_tag | string is search("ubuntu") + - import_role: + name: ceph-defaults - - set_fact: - ceph_uid: 167 - when: ceph_docker_image_tag | string is search("centos") or ceph_docker_image is search("rhceph") or ceph_docker_image_tag | string is search("fedora") + - import_role: + name: ceph-facts # NOTE: changed from file module to raw find command for performance reasons # The file module has to run checks on current ownership of all directories and files. This is unnecessary @@ -431,12 +381,6 @@ changed_when: false tasks: - - import_role: - name: ceph-defaults - - - import_role: - name: ceph-facts - - name: stop non-containerized ceph rgw(s) service: name: "ceph-radosgw@rgw.{{ ansible_hostname }}.{{ item.instance_name }}" @@ -487,13 +431,11 @@ - ceph-rbd-mirror@.service - ceph-rbd-mirror.target - - set_fact: - ceph_uid: 64045 - when: ceph_docker_image_tag | string is match("latest") or ceph_docker_image_tag | string is search("ubuntu") + - import_role: + name: ceph-defaults - - set_fact: - ceph_uid: 167 - when: ceph_docker_image_tag | string is search("centos") or ceph_docker_image is search("rhceph") or ceph_docker_image_tag | string is search("fedora") + - import_role: + name: ceph-facts # NOTE: changed from file module to raw find command for performance reasons # The file module has to run checks on current ownership of all directories and files. This is unnecessary @@ -503,12 +445,6 @@ changed_when: false tasks: - - import_role: - name: ceph-defaults - - - import_role: - name: ceph-facts - - import_role: name: ceph-handler @@ -544,13 +480,11 @@ enabled: no failed_when: false - - set_fact: - ceph_uid: 64045 - when: ceph_docker_image_tag | string is match("latest") or ceph_docker_image_tag | string is search("ubuntu") + - import_role: + name: ceph-defaults - - set_fact: - ceph_uid: 167 - when: ceph_docker_image_tag | string is search("centos") or ceph_docker_image is search("rhceph") or ceph_docker_image_tag | string is search("fedora") + - import_role: + name: ceph-facts # NOTE: changed from file module to raw find command for performance reasons # The file module has to run checks on current ownership of all directories and files. This is unnecessary @@ -560,12 +494,6 @@ changed_when: false tasks: - - import_role: - name: ceph-defaults - - - import_role: - name: ceph-facts - - import_role: name: ceph-handler diff --git a/roles/ceph-facts/tasks/facts.yml b/roles/ceph-facts/tasks/facts.yml index 7f1577c5b..6020ce1d5 100644 --- a/roles/ceph-facts/tasks/facts.yml +++ b/roles/ceph-facts/tasks/facts.yml @@ -218,16 +218,12 @@ ceph_uid: 167 when: - containerized_deployment | bool - - (ceph_docker_image_tag | string is search("latest") or ceph_docker_image_tag | string is search("centos") or ceph_docker_image_tag | string is search("fedora") + - (ceph_docker_image_tag | string is search("latest") + or ceph_docker_image_tag | string is search("centos") + or ceph_docker_image_tag | string is search("fedora") + or ceph_docker_image_tag | string is search("rhceph") or (ansible_distribution == 'RedHat')) -- name: set_fact ceph_uid for red hat - set_fact: - ceph_uid: 167 - when: - - containerized_deployment | bool - - ceph_docker_image is search("rhceph") - - name: set_fact rgw_hostname set_fact: rgw_hostname: "{% set _value = ansible_hostname -%} -- 2.39.5