]> git.apps.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
lint: set pipefail on shell tasks
authorGuillaume Abrioux <gabrioux@redhat.com>
Fri, 2 Oct 2020 09:23:42 +0000 (11:23 +0200)
committerGuillaume Abrioux <gabrioux@redhat.com>
Mon, 23 Nov 2020 07:33:47 +0000 (08:33 +0100)
Fix ansible lint 306 error:

[306] Shells that use pipes should set the pipefail option

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
infrastructure-playbooks/lv-teardown.yml
infrastructure-playbooks/purge-cluster.yml
infrastructure-playbooks/rolling_update.yml
infrastructure-playbooks/switch-from-non-containerized-to-containerized-ceph-daemons.yml
infrastructure-playbooks/take-over-existing-cluster.yml

index cab24250a274e9d9edcb4d5e76a0a2f286c35f2e..d06652d5a7e81723e0d833e049b6ae3831bd979e 100644 (file)
@@ -33,7 +33,9 @@
 
 # BEGIN TEARDOWN
   - name: find any existing osd filesystems
-    shell: "grep /var/lib/ceph/osd /proc/mounts | awk '{print $2}'"
+    shell: |
+      set -o pipefail;
+      grep /var/lib/ceph/osd /proc/mounts | awk '{print $2}'
     register: old_osd_filesystems
 
   - name: tear down any existing osd filesystems
index 91808c54e655644a2099c303ba9dbfd54b32b5fe..4b7e6959967d18c4d5b18e9270766d95902810e7 100644 (file)
     when: lvm_volumes is not defined
 
   - name: get osd numbers
-    shell: "if [ -d /var/lib/ceph/osd ] ; then ls /var/lib/ceph/osd | sed 's/.*-//' ; fi"
+    shell: |
+      set -o pipefail;
+      if [ -d /var/lib/ceph/osd ] ; then ls /var/lib/ceph/osd | sed 's/.*-//' ; fi
     register: osd_ids
     changed_when: false
 
   # NOTE(leseb): hope someone will find a more elegant way one day...
   - name: see if encrypted partitions are present
     shell: |
+      set -o pipefail;
       blkid -t TYPE=crypto_LUKS -s PARTLABEL -s PARTUUID | grep "ceph.*." | grep -o PARTUUID.* | cut -d '"' -f 2
     register: encrypted_ceph_partuuid
+    failed_when: false
 
   - name: get osd data and lockbox mount points
-    shell: "(grep /var/lib/ceph/osd /proc/mounts || echo -n) | awk '{ print $2 }'"
+    shell: |
+      set -o pipefail;
+      (grep /var/lib/ceph/osd /proc/mounts || echo -n) | awk '{ print $2 }'
     register: mounted_osd
     changed_when: false
 
     when: encrypted_ceph_partuuid.stdout_lines | length > 0
 
   - name: get payload_offset
-    shell: cryptsetup luksDump /dev/disk/by-partuuid/{{ item }} | awk '/Payload offset:/ { print $3 }'
+    shell: |
+      set -o pipefail;
+      cryptsetup luksDump /dev/disk/by-partuuid/{{ item }} | awk '/Payload offset:/ { print $3 }'
     register: payload_offset
     with_items: "{{ encrypted_ceph_partuuid.stdout_lines }}"
     when: encrypted_ceph_partuuid.stdout_lines | length > 0
 
   - name: wipe partitions
     shell: |
+      set -o pipefail;
       wipefs --all "{{ item }}"
       dd if=/dev/zero of="{{ item }}" bs=1 count=4096
     with_items: "{{ combined_devices_list }}"
 
   - name: zap ceph journal/block db/block wal partitions
     shell: |
+      set -o pipefail;
       # if the disk passed is a raw device AND the boot system disk
       if parted -s /dev/"{{ item }}" print | grep -sq boot; then
         echo "Looks like /dev/{{ item }} has a boot partition,"
index e18cc9ea4ad9682dc3aa086ed44563181afea644..fc393eaba468a03dd45d205ae71607eceeb8b0d2 100644 (file)
         name: ceph-facts
 
     - name: get osd numbers - non container
-      shell: "if [ -d /var/lib/ceph/osd ] ; then ls /var/lib/ceph/osd | sed 's/.*-//' ; fi"
+      shell: |
+        set -o pipefail;
+        if [ -d /var/lib/ceph/osd ] ; then ls /var/lib/ceph/osd | sed 's/.*-//' ; fi
       register: osd_ids
       changed_when: false
 
index 9c5f48fd6b58ed2722b22b052d1d981befd5fc57..6fd9c6ac6f2f99bafc0c79c39d9736eee9316789 100644 (file)
 
     - name: collect running osds
       shell: |
+        set -o pipefail;
         systemctl list-units | grep -E "loaded * active" | grep -Eo 'ceph-osd@[0-9]+.service|ceph-volume|ceph\.target'
       register: running_osds
       changed_when: false
index c8e54d999c8e7430ac170e33cc7306bcaf13edeb..ddd6b2fd1644e5b486683b7ae1718970010b236f 100644 (file)
@@ -37,6 +37,7 @@
   post_tasks:
     - name: get the name of the existing ceph cluster
       shell: |
+          set -o pipefail;
           basename $(grep --exclude '*.bak' -R fsid /etc/ceph/ | egrep -o '^[^.]*' | head -n 1)
       changed_when: false
       register: cluster_name