]> git.apps.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
switch_to_containers: do not re-set `ceph_uid`
authorGuillaume Abrioux <gabrioux@redhat.com>
Mon, 7 Oct 2019 09:08:44 +0000 (11:08 +0200)
committerDimitri Savineau <savineau.dimitri@gmail.com>
Mon, 7 Oct 2019 14:18:17 +0000 (10:18 -0400)
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 <gabrioux@redhat.com>
(cherry picked from commit fa9b42e98e32d2b3eff9605db044e37421d8b938)

infrastructure-playbooks/switch-from-non-containerized-to-containerized-ceph-daemons.yml
roles/ceph-facts/tasks/facts.yml

index 62bdcfac0bbdd3a09085ae412138d2ac225fa977..a52ee2394d1602649032d4f5c35b7d5851e8e5ca 100644 (file)
         - 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
       failed_when: false
 
   tasks:
-    - import_role:
-        name: ceph-defaults
-
-    - import_role:
-        name: ceph-facts
-
     - import_role:
         name: ceph-handler
 
         - 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
       changed_when: false
 
   tasks:
-    - import_role:
-        name: ceph-defaults
-
-    - import_role:
-        name: ceph-facts
-
     - import_role:
         name: ceph-handler
 
         - /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
       when: osd_running.rc != 0
 
   tasks:
-    - import_role:
-        name: ceph-defaults
-
-    - import_role:
-        name: ceph-facts
-
     - import_role:
         name: ceph-handler
 
         - 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
       changed_when: false
 
   tasks:
-    - import_role:
-        name: ceph-defaults
-
-    - import_role:
-        name: ceph-facts
-
     - import_role:
         name: ceph-handler
 
   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
       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 }}"
         - 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
       changed_when: false
 
   tasks:
-    - import_role:
-        name: ceph-defaults
-
-    - import_role:
-        name: ceph-facts
-
     - import_role:
         name: ceph-handler
 
         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
       changed_when: false
 
   tasks:
-    - import_role:
-        name: ceph-defaults
-
-    - import_role:
-        name: ceph-facts
-
     - import_role:
         name: ceph-handler
 
index 7f1577c5bc2b014c263b3b405712869a4242a137..6020ce1d519dd31b1fd0dacb146a94af889afda8 100644 (file)
     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 -%}