Skip to content

Commit

Permalink
Make edpm_nodes_validation role compliant with ansible-lint `produc…
Browse files Browse the repository at this point in the history
…tion` profile

- Added `changed_when`/`failed_when` in `shell` task
- Fixed spacing issues
- Fixed task name avoiding templating inside it

Signed-off-by: Roberto Alfieri <[email protected]>
  • Loading branch information
rebtoor committed Oct 10, 2023
1 parent 010f5af commit 5d8323b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions roles/edpm_nodes_validation/tasks/ping.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,19 @@
INT=$(ip ro get {{ controller }} | head -1 | sed -nr "s/.* dev (\w+) .*/\1/p")
MTU=$(cat /sys/class/net/${INT}/mtu 2>/dev/null || echo "0")
echo "$INT $MTU"
changed_when:
- _nic_mtu.stdout.split()[0] != ""
- _nic_mtu.stdout.split()[1] != ""
failed_when:
- _nic_mtu.stdout.split()[0] == ""
- _nic_mtu.stdout.split()[1] == ""
- name: Set interface vars
ansible.builtin.set_fact:
_nic: "{{ _nic_mtu.stdout.split()[0] | default('lo') }}"
_mtu: "{{ _nic_mtu.stdout.split()[1] | default(0) | int - 28 }}"
- name: Network availability validation block
when:
- not ansible_check_mode|bool
- not ansible_check_mode | bool
- _nic != 'lo'
block:
- name: Check IP responsiveness
Expand All @@ -41,7 +47,7 @@
register: ping_result
until: ping_result.rc == 0

- name: Validate packet with {{ _mtu }} MTU size can reach controller from {{ _nic }}
- name: Validate packet with given MTU size can reach controller from {{ _nic }}
ansible.builtin.command: "{{ _ping_cmd }} -w 10 -s {{ _mtu }} -c 5 {{ controller }}"
retries: 10
delay: 60
Expand Down

0 comments on commit 5d8323b

Please sign in to comment.