]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
lint: commands should not change things
authorGuillaume Abrioux <gabrioux@redhat.com>
Fri, 2 Oct 2020 10:55:53 +0000 (12:55 +0200)
committerGuillaume Abrioux <gabrioux@redhat.com>
Tue, 24 Nov 2020 09:39:03 +0000 (10:39 +0100)
Fix ansible lint 301 error:

[301] Commands should not change things if nothing needs doing

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
(cherry picked from commit 5450de58b37cb169adecd87f547551b976d4b9bf)

infrastructure-playbooks/lv-teardown.yml
infrastructure-playbooks/purge-cluster.yml
infrastructure-playbooks/purge-container-cluster.yml
infrastructure-playbooks/rolling_update.yml
infrastructure-playbooks/shrink-mds.yml
infrastructure-playbooks/shrink-mgr.yml
infrastructure-playbooks/shrink-mon.yml
infrastructure-playbooks/shrink-osd.yml
infrastructure-playbooks/shrink-rbdmirror.yml
infrastructure-playbooks/shrink-rgw.yml
infrastructure-playbooks/switch-from-non-containerized-to-containerized-ceph-daemons.yml

index d06652d5a7e81723e0d833e049b6ae3831bd979e..7ba8ae70e4145366c96000ca405b7671b570fd45 100644 (file)
       set -o pipefail;
       grep /var/lib/ceph/osd /proc/mounts | awk '{print $2}'
     register: old_osd_filesystems
+    changed_when: false
 
-  - name: tear down any existing osd filesystems
-    command: "umount -v {{ item }}"
+  - name: tear down any existing osd filesystem
+    mount:
+      path: "{{ item }}"
+      state: unmounted
     with_items: "{{ old_osd_filesystems.stdout_lines }}"
 
   - name: kill all lvm commands that may have been hung
     command: "killall -q lvcreate pvcreate vgcreate lvconvert || echo -n"
     failed_when: false
+    changed_when: false
 
   ## Logcal Vols
   - name: tear down existing lv for bucket index
   ## Physical Vols
   - name: tear down pv for nvme device
     command: "pvremove --force --yes {{ nvme_device }}"
+    changed_when: false
 
   - name: tear down pv for each hdd device
     command: "pvremove --force --yes {{ item }}"
+    changed_when: false
     with_items: "{{ hdd_devices }}"
index d83c1472adba3f0467754a60425d73651e8efc59..d153ce36571eb8dd4fd6f8618efbed4a7b2d17c2 100644 (file)
@@ -87,6 +87,7 @@
 
     - name: ensure cephfs mountpoint(s) are unmounted
       command: umount -a -t ceph
+      changed_when: false
 
     - name: find mapped rbd ids
       find:
@@ -96,6 +97,7 @@
 
     - name: use sysfs to unmap rbd devices
       shell: "echo {{ item.path | basename }} > /sys/bus/rbd/remove_single_major"
+      changed_when: false
       with_items: "{{ rbd_mapped_ids.files }}"
 
     - name: unload ceph kernel modules
       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
+    changed_when: false
 
   - name: get osd data and lockbox mount points
     shell: |
 
   - name: drop all cache
     shell: "sync && sleep 1 && echo 3 > /proc/sys/vm/drop_caches"
+    changed_when: false
 
   - name: umount osd data partition
-    shell: umount {{ item }}
+    mount:
+      path: "{{ item }}"
+      state: unmounted
     with_items: "{{ mounted_osd.stdout_lines }}"
 
   - name: remove osd mountpoint tree
 
   - name: get physical sector size
     command: blockdev --getpbsz /dev/disk/by-partuuid/{{ item }}
+    changed_when: false
     with_items: "{{ encrypted_ceph_partuuid.stdout_lines }}"
     when: encrypted_ceph_partuuid.stdout_lines | length > 0
     register: phys_sector_size
 
   - name: wipe dmcrypt device
     command: dd if=/dev/zero of=/dev/disk/by-partuuid/{{ item.0 }} bs={{ item.1.stdout }} count={{ item.2.stdout }} oflag=direct
+    changed_when: false
     with_together:
       - "{{ encrypted_ceph_partuuid.stdout_lines }}"
       - "{{ payload_offset.results }}"
   - name: get ceph data partitions
     shell: |
       blkid -o device -t PARTLABEL="ceph data"
+    changed_when: false
     failed_when: false
     register: ceph_data_partition_to_erase_path
 
   - name: get ceph lockbox partitions
     shell: |
       blkid -o device -t PARTLABEL="ceph lockbox"
+    changed_when: false
     failed_when: false
     register: ceph_lockbox_partition_to_erase_path
 
   - name: see if ceph-volume is installed
-    shell: "command -v ceph-volume"
+    command: command -v ceph-volume
+    changed_when: false
     failed_when: false
     register: ceph_volume_present
 
   - name: get ceph block partitions
     shell: |
       blkid -o device -t PARTLABEL="ceph block"
+    changed_when: false
     failed_when: false
     register: ceph_block_partition_to_erase_path
 
   - name: get ceph journal partitions
     shell: |
       blkid -o device -t PARTLABEL="ceph journal"
+    changed_when: false
     failed_when: false
     register: ceph_journal_partition_to_erase_path
 
   - name: get ceph db partitions
     shell: |
       blkid -o device -t PARTLABEL="ceph block.db"
+    changed_when: false
     failed_when: false
     register: ceph_db_partition_to_erase_path
 
   - name: get ceph wal partitions
     shell: |
       blkid -o device -t PARTLABEL="ceph block.wal"
+    changed_when: false
     failed_when: false
     register: ceph_wal_partition_to_erase_path
 
   - name: resolve parent device
     command: lsblk --nodeps -no pkname "{{ item }}"
     register: tmp_resolved_parent_device
+    changed_when: false
     with_items: "{{ combined_devices_list }}"
 
   - name: set_fact resolved_parent_device
       set -o pipefail;
       wipefs --all "{{ item }}"
       dd if=/dev/zero of="{{ item }}" bs=1 count=4096
+    changed_when: false
     with_items: "{{ combined_devices_list }}"
 
   - name: zap ceph journal/block db/block wal partitions
       partprobe /dev/"{{ item }}"
       udevadm settle --timeout=600
     with_items: "{{ resolved_parent_device }}"
+    changed_when: false
 
 - name: purge ceph mon cluster
 
   - name: request data removal
     local_action:
       module: command
-        echo requesting data removal
+        echo requesting data removal  # noqa 301
     become: false
     notify: remove data
 
   - name: check for anything running ceph
     command: "ps -u ceph -U ceph"
     register: check_for_running_ceph
+    changed_when: false
     failed_when: check_for_running_ceph.rc == 0
 
   - name: find ceph systemd unit files to remove
index e9d2f888f469ab9f2d5408e2bfa783af9cd9225e..0d7b34fa03180804942af33816fdbe2aafbbf62b 100644 (file)
@@ -71,6 +71,7 @@
 
     - name: ensure cephfs mountpoint are unmounted
       command: umount -a -t ceph
+      changed_when: false
 
     - name: find mapped rbd ids
       find:
@@ -80,6 +81,7 @@
 
     - name: use sysfs to unmap rbd devices
       shell: "echo {{ item.path | basename }} > /sys/bus/rbd/remove_single_major"
+      changed_when: false
       with_items: "{{ rbd_mapped_ids.files }}"
 
     - name: unload ceph kernel modules
     shell: |
       systemctl list-units --all | grep -oE "ceph-osd@([0-9]+).service"
     register: osd_units
+    changed_when: false
     ignore_errors: true
 
   - name: disable ceph osd service
 
     - name: remove ceph container image
       command: "{{ container_binary }} rmi {{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }}"
+      changed_when: false
       tags:
         - remove_img
 
 
   - name: remove ceph data
     shell: rm -rf /var/lib/ceph/*
+    changed_when: false
 
   # (todo): remove this when we are able to manage docker
   # service on atomic host.
index 1eadba755998afab34fe1baee89453c34b4fa940..e9be2527ef7407046a606951fd506a5a78a57912 100644 (file)
 
     - name: set osd flags
       command: "{{ container_exec_cmd | default('') }} ceph --cluster {{ cluster }} osd set {{ item }}"
+      changed_when: false
       with_items:
         - noout
         - nodeep-scrub
 
     - name: get num_pgs - non container
       command: "{{ container_exec_cmd_update_osd|default('') }} ceph --cluster {{ cluster }} pg stat --format json"
+      changed_when: false
       register: ceph_pgs
       delegate_to: "{{ groups[mon_group_name][0] }}"
 
 
     - name: unset osd flags
       command: "{{ container_exec_cmd_update_osd | default('') }} ceph osd unset {{ item }} --cluster {{ cluster }}"
+      changed_when: false
       with_items:
         - noout
         - nodeep-scrub
 
     - name: show ceph status
       command: "{{ container_exec_cmd_status|default('') }} ceph --cluster {{ cluster }} -s"
+      changed_when: false
       run_once: True
       delegate_to: "{{ groups[mon_group_name][0] }}"
 
       command: "{{ container_exec_cmd_status|default('') }} ceph --cluster {{ cluster }} versions"
       run_once: True
       delegate_to: "{{ groups[mon_group_name][0] }}"
+      changed_when: false
index 104f43b854bb850170719322d834357bdf9cdb65..3c8aee3ecd05fb05ace160d53e531b03c9d37ab4 100644 (file)
@@ -66,6 +66,7 @@
 
     - name: exit playbook, if can not connect to the cluster
       command: "{{ container_exec_cmd | default('') }} timeout 5 ceph --cluster {{ cluster }} health"
+      changed_when: false
       register: ceph_health
       until: ceph_health is succeeded
       retries: 5
     # removes the MDS from the FS map.
     - name: exit mds when containerized deployment
       command: "{{ container_exec_cmd | default('') }} ceph tell mds.{{ mds_to_kill_hostname }} exit"
+      changed_when: false
       when: containerized_deployment | bool
 
     - name: get ceph status
       command: "{{ container_exec_cmd | default('') }} ceph --cluster {{ cluster }} -s -f json"
       register: ceph_status
+      changed_when: false
 
     - name: set_fact current_max_mds
       set_fact:
   post_tasks:
     - name: show ceph health
       command: "{{ container_exec_cmd | default('') }} ceph --cluster {{ cluster }} -s"
+      changed_when: false
\ No newline at end of file
index 4cd57aef7046b397e1e85d8d5e599650068fb046..c4fbc0f900476ce382e4e23241e511e2aa7e0a0e 100644 (file)
@@ -44,6 +44,7 @@
     - name: exit playbook, if can not connect to the cluster
       command: "{{ container_exec_cmd | default('') }} timeout 5 ceph --cluster {{ cluster }} health"
       register: ceph_health
+      changed_when: false
       until: ceph_health is succeeded
       retries: 5
       delay: 2
     - name: fail if the mgr is reported in ceph mgr dump
       command: "{{ container_exec_cmd | default('') }} ceph --cluster {{ cluster }} mgr dump -f json"
       register: mgr_dump
+      changed_when: false
       failed_when: mgr_to_kill_hostname in (([mgr_dump.stdout | from_json] | map(attribute='active_name') | list) + (mgr_dump.stdout | from_json)['standbys'] | map(attribute='name') | list)
       until: mgr_to_kill_hostname not in (([mgr_dump.stdout | from_json] | map(attribute='active_name') | list) + (mgr_dump.stdout | from_json)['standbys'] | map(attribute='name') | list)
       retries: 12
   post_tasks:
     - name: show ceph health
       command: "{{ container_exec_cmd | default('') }} ceph --cluster {{ cluster }} -s"
+      changed_when: false
\ No newline at end of file
index 868559be38b12fdab6b349feed7410353df91e49..df2ae60bd46cf1d15e70a7aff995fa74d16046c9 100644 (file)
@@ -82,6 +82,7 @@
     - name: exit playbook, if can not connect to the cluster
       command: "{{ container_exec_cmd }} timeout 5 ceph --cluster {{ cluster }} health"
       register: ceph_health
+      changed_when: false
       until: ceph_health.stdout.find("HEALTH") > -1
       delegate_to: "{{ mon_host }}"
       retries: 5
 
     - name: remove monitor from the quorum
       command: "{{ container_exec_cmd }} ceph --cluster {{ cluster }} mon remove {{ mon_to_kill_hostname }}"
+      changed_when: false
       failed_when: false
       delegate_to: "{{ mon_host }}"
 
     - name: verify the monitor is out of the cluster
       command: "{{ container_exec_cmd }} ceph --cluster {{ cluster }} quorum_status -f json"
       delegate_to: "{{ mon_host }}"
+      changed_when: false
       failed_when: false
       register: result
       until: mon_to_kill_hostname not in (result.stdout | from_json)['quorum_names']
     - name: show ceph health
       command: "{{ container_exec_cmd }} ceph --cluster {{ cluster }} -s"
       delegate_to: "{{ mon_host }}"
+      changed_when: false
 
     - name: show ceph mon status
       command: "{{ container_exec_cmd }} ceph --cluster {{ cluster }} mon stat"
       delegate_to: "{{ mon_host }}"
+      changed_when: false
\ No newline at end of file
index b4bb69af13387b656e5c02ce9bf156f299e575a5..366faccd0e8c92c1af672fb85cfdd070f08dd093 100644 (file)
     - name: exit playbook, if can not connect to the cluster
       command: "{{ container_exec_cmd }} timeout 5 ceph --cluster {{ cluster }} health"
       register: ceph_health
+      changed_when: false
       until: ceph_health.stdout.find("HEALTH") > -1
       retries: 5
       delay: 2
 
     - name: find the host(s) where the osd(s) is/are running on
       command: "{{ container_exec_cmd }} ceph --cluster {{ cluster }} osd find {{ item }}"
+      changed_when: false
       with_items: "{{ osd_to_kill.split(',') }}"
       register: find_osd_hosts
 
 
     - name: get ceph-volume lvm list data
       command: "{{ container_run_cmd }} lvm list --format json"
+      changed_when: false
       register: _lvm_list_data
       delegate_to: "{{ item.0 }}"
       loop: "{{ _osd_hosts }}"
 
     - name: mark osd(s) out of the cluster
       command: "{{ container_exec_cmd }} ceph --cluster {{ cluster }} osd out {{ osd_to_kill.replace(',', ' ') }}"
+      changed_when: false
       run_once: true
 
     - name: stop osd(s) service
 
     - name: ensure osds are marked down
       command: "{{ container_exec_cmd }} ceph --cluster {{ cluster }} osd down {{ osd_to_kill.replace(',', ' ') }}"
+      changed_when: false
       run_once: true
       delegate_to: "{{ groups[mon_group_name][0] }}"
 
     - name: purge osd(s) from the cluster
       command: "{{ container_exec_cmd }} ceph --cluster {{ cluster }} osd purge {{ item }} --yes-i-really-mean-it"
+      changed_when: false
       run_once: true
       with_items: "{{ osd_to_kill.split(',') }}"
 
 
     - name: show ceph health
       command: "{{ container_exec_cmd }} ceph --cluster {{ cluster }} -s"
+      changed_when: false
 
     - name: show ceph osd tree
       command: "{{ container_exec_cmd }} ceph --cluster {{ cluster }} osd tree"
+      changed_when: false
index d87130044bfe3424cfcf717427e92bfb17aabc1e..3e65393306e666dcfac41c52fae3ed03df9e8eb7 100644 (file)
@@ -69,6 +69,7 @@
     - name: exit playbook, if can not connect to the cluster
       command: "{{ container_exec_cmd | default('') }} timeout 5 ceph --cluster {{ cluster }} service dump -f json"
       register: ceph_health
+      changed_when: false
       until: ceph_health is succeeded
       retries: 5
       delay: 2
 
     - name: show ceph health
       command: "{{ container_exec_cmd | default('') }} ceph --cluster {{ cluster }} -s"
+      changed_when: false
index 88231b2c21994de188913ec59a5afe0e4d1036be..219ae310da2f5e0f396ecd2987d943154e09f53f 100644 (file)
@@ -71,6 +71,7 @@
     - name: exit playbook, if can not connect to the cluster
       command: "{{ container_exec_cmd | default('') }} timeout 5 ceph --cluster {{ cluster }} health"
       register: ceph_health
+      changed_when: false
       until: ceph_health is succeeded
       retries: 5
       delay: 2
@@ -78,6 +79,7 @@
     - name: get rgw instances
       command: "{{ container_exec_cmd | default('') }} ceph --cluster {{ cluster }} service dump -f json"
       register: rgw_instances
+      changed_when: false
 
 
     - name: exit playbook, if the rgw_to_kill doesn't exist
       command: "systemctl is-active ceph-radosgw@rgw.{{ rgw_to_kill }}"
       register: rgw_to_kill_status
       failed_when: rgw_to_kill_status.rc == 0
+      changed_when: false
       delegate_to: "{{ rgw_host }}"
       retries: 5
       delay: 2
     - name: exit if rgw_to_kill is reported in ceph status
       command: "{{ container_exec_cmd | default('') }} ceph --cluster {{ cluster }} service dump -f json"
       register: ceph_status
+      changed_when: false
       failed_when:
         - (ceph_status.stdout | from_json).services.rgw is defined
         - rgw_to_kill in (ceph_status.stdout | from_json).services.rgw.daemons.keys() | list
   post_tasks:
     - name: show ceph health
       command: "{{ container_exec_cmd | default('')}} ceph --cluster {{ cluster }} -s"
+      changed_when: false
index 6fd9c6ac6f2f99bafc0c79c39d9736eee9316789..4f54dac333aac3b567c965b8cb0e75d9b11594a6 100644 (file)
     - name: waiting for the monitor to join the quorum...
       command: "{{ container_exec_cmd }} ceph --cluster {{ cluster }} quorum_status --format json"
       register: ceph_health_raw
+      changed_when: false
       until: >
         hostvars[mon_host]['ansible_hostname'] in (ceph_health_raw.stdout | from_json)["quorum_names"]
       retries: "{{ health_mon_check_retries }}"
 
     - name: set osd flags
       command: "{{ container_exec_cmd | default('') }} ceph --cluster {{ cluster }} osd set {{ item }}"
+      changed_when: false
       with_items:
         - noout
         - nodeep-scrub
       delegate_to: "{{ groups[mon_group_name][0] }}"
       retries: "{{ health_osd_check_retries }}"
       delay: "{{ health_osd_check_delay }}"
+      changed_when: false
 
 
 - name: unset osd flags
 
     - name: set osd flags
       command: "{{ container_exec_cmd | default('') }} ceph --cluster {{ cluster }} osd unset {{ item }}"
+      changed_when: false
       with_items:
         - noout
         - nodeep-scrub