]> git.apps.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
switch_to_containers: optimize ownership change
authorGuillaume Abrioux <gabrioux@redhat.com>
Mon, 7 Oct 2019 07:19:50 +0000 (09:19 +0200)
committerDimitri Savineau <savineau.dimitri@gmail.com>
Mon, 7 Oct 2019 14:18:17 +0000 (10:18 -0400)
As per https://github.com/ceph/ceph-ansible/pull/4323#issuecomment-538420164

using `find` command should be faster.

Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1757400
Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
Co-Authored-by: Giulio Fidente <gfidente@redhat.com>
(cherry picked from commit c5d0c90bb7d8382fde2f07820c2d8547c8a3603e)

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

index 14be66e96dc28c198cd0589ece975ed6ac9162cd..62bdcfac0bbdd3a09085ae412138d2ac225fa977 100644 (file)
          ceph_uid: 167
       when: ceph_docker_image is search("rhceph")
 
-    # NOTE: changed from file module to raw chown command for performance reasons
+    # 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
     # as in this case we know we want all owned by ceph user
     - name: set proper ownership on ceph directories
-      command: "chown -R {{ ceph_uid }} /var/lib/ceph /etc/ceph"
+      command: "find /var/lib/ceph /etc/ceph -not -( -user {{ ceph_uid }} -or -group {{ ceph_uid }} -) -execdir chown {{ ceph_uid }}:{{ ceph_uid }} {} +"
       changed_when: false
 
     - name: check for existing old leveldb file extension (ldb)
         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")
 
-    # NOTE: changed from file module to raw chown command for performance reasons
+    # 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
     # as in this case we know we want all owned by ceph user
     - name: set proper ownership on ceph directories
-      command: "chown -R {{ ceph_uid }} /var/lib/ceph /etc/ceph"
+      command: "find /var/lib/ceph /etc/ceph -not -( -user {{ ceph_uid }} -or -group {{ ceph_uid }} -) -execdir chown {{ ceph_uid }}:{{ ceph_uid }} {} +"
       changed_when: false
 
   tasks:
          ceph_uid: 167
       when: ceph_docker_image is search("rhceph")
 
-    # NOTE: changed from file module to raw chown command for performance reasons
+    # 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
     # as in this case we know we want all owned by ceph user
     - name: set proper ownership on ceph directories
-      command: "chown --verbose -R {{ ceph_uid }} /var/lib/ceph /etc/ceph"
+      command: "find /var/lib/ceph /etc/ceph -not -( -user {{ ceph_uid }} -or -group {{ ceph_uid }} -) -execdir chown {{ ceph_uid }}:{{ ceph_uid }} {} +"
       changed_when: false
 
     - name: check for existing old leveldb file extension (ldb)
         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")
 
-    # NOTE: changed from file module to raw chown command for performance reasons
+    # 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
     # as in this case we know we want all owned by ceph user
     - name: set proper ownership on ceph directories
-      command: "chown -R {{ ceph_uid }} /var/lib/ceph /etc/ceph"
+      command: "find /var/lib/ceph /etc/ceph -not -( -user {{ ceph_uid }} -or -group {{ ceph_uid }} -) -execdir chown {{ ceph_uid }}:{{ ceph_uid }} {} +"
       changed_when: false
 
   tasks:
         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")
 
-    # NOTE: changed from file module to raw chown command for performance reasons
+    # 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
     # as in this case we know we want all owned by ceph user
     - name: set proper ownership on ceph directories
-      command: "chown -R {{ ceph_uid }} /var/lib/ceph /etc/ceph"
+      command: "find /var/lib/ceph /etc/ceph -not -( -user {{ ceph_uid }} -or -group {{ ceph_uid }} -) -execdir chown {{ ceph_uid }}:{{ ceph_uid }} {} +"
       changed_when: false
 
   tasks:
         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")
 
-    # NOTE: changed from file module to raw chown command for performance reasons
+    # 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
     # as in this case we know we want all owned by ceph user
     - name: set proper ownership on ceph directories
-      command: "chown -R {{ ceph_uid }} /var/lib/ceph /etc/ceph"
+      command: "find /var/lib/ceph /etc/ceph -not -( -user {{ ceph_uid }} -or -group {{ ceph_uid }} -) -execdir chown {{ ceph_uid }}:{{ ceph_uid }} {} +"
       changed_when: false
 
   tasks:
         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")
 
-    # NOTE: changed from file module to raw chown command for performance reasons
+    # 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
     # as in this case we know we want all owned by ceph user
     - name: set proper ownership on ceph directories
-      command: "chown -R {{ ceph_uid }} /var/lib/ceph /etc/ceph"
+      command: "find /var/lib/ceph /etc/ceph -not -( -user {{ ceph_uid }} -or -group {{ ceph_uid }} -) -execdir chown {{ ceph_uid }}:{{ ceph_uid }} {} +"
       changed_when: false
 
   tasks: