Skip to content

Commit

Permalink
Fix "no-changed-when" violations.
Browse files Browse the repository at this point in the history
Adding the missing "changed_when" conditional.
Fixing 5 violations:
  no-changed-when: Commands should not change things if nothing needs doing.

Signed-off-by: Pavel Bar <[email protected]>
Bug-Url: https://bugzilla.redhat.com/2097332
  • Loading branch information
barpavel committed Jul 3, 2022
1 parent e4a2667 commit 1ba602a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion automation/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ cd "$COLLECTION_DIR"
ansible-test sanity
antsibull-changelog lint -v
ansible-lint roles/* --exclude roles/hosted_engine_setup --exclude roles/disaster_recovery --exclude roles/remove_stale_lun -x experimental
ansible-lint -x no-changed-when,ignore-errors roles/disaster_recovery roles/remove_stale_lun
ansible-lint -x ignore-errors roles/disaster_recovery roles/remove_stale_lun

cd "$ROOT_PATH"

Expand Down
1 change: 1 addition & 0 deletions roles/disaster_recovery/tasks/generate_mapping.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
-p "{{ password }}"
-c "{{ ca }}"
-f "{{ var_file }}"
changed_when: true
run_once: true
tags:
- generate_mapping
1 change: 1 addition & 0 deletions roles/disaster_recovery/tasks/recover/print_info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

- name: Print report file
ansible.builtin.command: cat /tmp/{{ dr_report_file }}
changed_when: false
register: content

- name: Print report file to stdout
Expand Down
3 changes: 3 additions & 0 deletions roles/remove_stale_lun/tasks/remove_mpath_device.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,21 @@
for dev in {{ lun_wwid }}; do
set -euo pipefail && dmsetup deps -o devname $dev | cut -f 2 | cut -c 3- | tr -d "()" | tr "\r\n" " ";
done
changed_when: false
register: disks
check_mode: "no"

- name: Remove from multipath device.
ansible.builtin.shell: "for dev in {{ lun_wwid }}; do multipath -f $dev || exit 1; done"
changed_when: true
register: flush_results
retries: 6
check_mode: "no"
until: flush_results.rc == 0

- name: Remove each path from the SCSI subsystem.
ansible.builtin.shell: "for dev in {{ item.stdout }}; do echo 1 > /sys/block/$dev/device/delete; done"
changed_when: true
check_mode: "no"
with_items:
- "{{ disks }}"

0 comments on commit 1ba602a

Please sign in to comment.