mirror of https://github.com/ceph/ceph-ansible.git
lint: set pipefail on shell tasks
Fix ansible lint 306 error:
[306] Shells that use pipes should set the pipefail option
Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
(cherry picked from commit 1879c26eb9
)
pull/6067/head
parent
ffc63ad5f5
commit
1d4cd3328a
|
@ -33,7 +33,9 @@
|
||||||
|
|
||||||
# BEGIN TEARDOWN
|
# BEGIN TEARDOWN
|
||||||
- name: find any existing osd filesystems
|
- 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
|
register: old_osd_filesystems
|
||||||
|
|
||||||
- name: tear down any existing osd filesystems
|
- name: tear down any existing osd filesystems
|
||||||
|
|
|
@ -386,7 +386,9 @@
|
||||||
when: lvm_volumes is not defined
|
when: lvm_volumes is not defined
|
||||||
|
|
||||||
- name: get osd numbers
|
- 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
|
register: osd_ids
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
|
||||||
|
@ -409,11 +411,15 @@
|
||||||
# NOTE(leseb): hope someone will find a more elegant way one day...
|
# NOTE(leseb): hope someone will find a more elegant way one day...
|
||||||
- name: see if encrypted partitions are present
|
- name: see if encrypted partitions are present
|
||||||
shell: |
|
shell: |
|
||||||
|
set -o pipefail;
|
||||||
blkid -t TYPE=crypto_LUKS -s PARTLABEL -s PARTUUID | grep "ceph.*." | grep -o PARTUUID.* | cut -d '"' -f 2
|
blkid -t TYPE=crypto_LUKS -s PARTLABEL -s PARTUUID | grep "ceph.*." | grep -o PARTUUID.* | cut -d '"' -f 2
|
||||||
register: encrypted_ceph_partuuid
|
register: encrypted_ceph_partuuid
|
||||||
|
failed_when: false
|
||||||
|
|
||||||
- name: get osd data and lockbox mount points
|
- 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
|
register: mounted_osd
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
|
||||||
|
@ -455,7 +461,9 @@
|
||||||
when: encrypted_ceph_partuuid.stdout_lines | length > 0
|
when: encrypted_ceph_partuuid.stdout_lines | length > 0
|
||||||
|
|
||||||
- name: get payload_offset
|
- 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
|
register: payload_offset
|
||||||
with_items: "{{ encrypted_ceph_partuuid.stdout_lines }}"
|
with_items: "{{ encrypted_ceph_partuuid.stdout_lines }}"
|
||||||
when: encrypted_ceph_partuuid.stdout_lines | length > 0
|
when: encrypted_ceph_partuuid.stdout_lines | length > 0
|
||||||
|
@ -563,12 +571,14 @@
|
||||||
|
|
||||||
- name: wipe partitions
|
- name: wipe partitions
|
||||||
shell: |
|
shell: |
|
||||||
|
set -o pipefail;
|
||||||
wipefs --all "{{ item }}"
|
wipefs --all "{{ item }}"
|
||||||
dd if=/dev/zero of="{{ item }}" bs=1 count=4096
|
dd if=/dev/zero of="{{ item }}" bs=1 count=4096
|
||||||
with_items: "{{ combined_devices_list }}"
|
with_items: "{{ combined_devices_list }}"
|
||||||
|
|
||||||
- name: zap ceph journal/block db/block wal partitions
|
- name: zap ceph journal/block db/block wal partitions
|
||||||
shell: |
|
shell: |
|
||||||
|
set -o pipefail;
|
||||||
# if the disk passed is a raw device AND the boot system disk
|
# if the disk passed is a raw device AND the boot system disk
|
||||||
if parted -s /dev/"{{ item }}" print | grep -sq boot; then
|
if parted -s /dev/"{{ item }}" print | grep -sq boot; then
|
||||||
echo "Looks like /dev/{{ item }} has a boot partition,"
|
echo "Looks like /dev/{{ item }} has a boot partition,"
|
||||||
|
|
|
@ -365,7 +365,9 @@
|
||||||
name: ceph-facts
|
name: ceph-facts
|
||||||
|
|
||||||
- name: get osd numbers - non container
|
- 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
|
register: osd_ids
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
|
||||||
|
|
|
@ -235,6 +235,7 @@
|
||||||
|
|
||||||
- name: collect running osds
|
- name: collect running osds
|
||||||
shell: |
|
shell: |
|
||||||
|
set -o pipefail;
|
||||||
systemctl list-units | grep -E "loaded * active" | grep -Eo 'ceph-osd@[0-9]+.service|ceph-volume|ceph\.target'
|
systemctl list-units | grep -E "loaded * active" | grep -Eo 'ceph-osd@[0-9]+.service|ceph-volume|ceph\.target'
|
||||||
register: running_osds
|
register: running_osds
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
post_tasks:
|
post_tasks:
|
||||||
- name: get the name of the existing ceph cluster
|
- name: get the name of the existing ceph cluster
|
||||||
shell: |
|
shell: |
|
||||||
|
set -o pipefail;
|
||||||
basename $(grep --exclude '*.bak' -R fsid /etc/ceph/ | egrep -o '^[^.]*' | head -n 1)
|
basename $(grep --exclude '*.bak' -R fsid /etc/ceph/ | egrep -o '^[^.]*' | head -n 1)
|
||||||
changed_when: false
|
changed_when: false
|
||||||
register: cluster_name
|
register: cluster_name
|
||||||
|
|
Loading…
Reference in New Issue