switch_to_containers: optimize ownership change

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 c5d0c90bb7)
pull/4595/head
Guillaume Abrioux 2019-10-07 09:19:50 +02:00 committed by Dimitri Savineau
parent 70ac841153
commit 07489c9f8e
1 changed files with 14 additions and 14 deletions

View File

@ -92,11 +92,11 @@
ceph_uid: 167 ceph_uid: 167
when: ceph_docker_image is search("rhceph") 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 # 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 # as in this case we know we want all owned by ceph user
- name: set proper ownership on ceph directories - 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 changed_when: false
- name: check for existing old leveldb file extension (ldb) - name: check for existing old leveldb file extension (ldb)
@ -168,11 +168,11 @@
ceph_uid: 167 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") 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 # 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 # as in this case we know we want all owned by ceph user
- name: set proper ownership on ceph directories - 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 changed_when: false
roles: roles:
@ -238,11 +238,11 @@
ceph_uid: 167 ceph_uid: 167
when: ceph_docker_image is search("rhceph") 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 # 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 # as in this case we know we want all owned by ceph user
- name: set proper ownership on ceph directories - 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 changed_when: false
- name: check for existing old leveldb file extension (ldb) - name: check for existing old leveldb file extension (ldb)
@ -335,11 +335,11 @@
ceph_uid: 167 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") 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 # 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 # as in this case we know we want all owned by ceph user
- name: set proper ownership on ceph directories - 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 changed_when: false
roles: roles:
@ -377,11 +377,11 @@
ceph_uid: 167 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") 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 # 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 # as in this case we know we want all owned by ceph user
- name: set proper ownership on ceph directories - 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 changed_when: false
roles: roles:
@ -419,11 +419,11 @@
ceph_uid: 167 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") 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 # 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 # as in this case we know we want all owned by ceph user
- name: set proper ownership on ceph directories - 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 changed_when: false
roles: roles:
@ -465,11 +465,11 @@
ceph_uid: 167 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") 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 # 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 # as in this case we know we want all owned by ceph user
- name: set proper ownership on ceph directories - 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 changed_when: false
roles: roles: