Avoid unnecessary use of 'and' in 'when' conditions

This commit is contained in:
Jakub Jelen 2022-04-12 11:40:35 +02:00 committed by Jakub Jelen
parent 09b4214a51
commit bcbdf92182
3 changed files with 11 additions and 7 deletions

View file

@ -25,6 +25,6 @@
main_sshd_config: /etc/ssh/sshd_config.d/00-ansible_system_role.conf
main_sshd_config_name: 00-ansible_system_role.conf
main_sshd_config_path: /etc/ssh/sshd_config.d/
when: >
ansible_facts['os_family'] == 'RedHat' and
ansible_facts['distribution_major_version']|int > 8
when:
- ansible_facts['os_family'] == 'RedHat'
- ansible_facts['distribution_major_version']|int > 8

View file

@ -74,7 +74,8 @@
- "config.content | b64decode | regex_search('Match address \\*\\s*PasswordAuthentication yes')"
- "config.content | b64decode | regex_search('Match address \\*\\s*PasswordAuthentication no')"
when:
- ansible_facts['os_family'] == 'RedHat' and ansible_facts['distribution_major_version'] == '6'
- ansible_facts['os_family'] == 'RedHat'
- ansible_facts['distribution_major_version'] == '6'
- name: Check content of configuration file
assert:

View file

@ -39,7 +39,8 @@
that:
- "'HostKey /etc/ssh/ssh_host_ed25519_key' in config.content | b64decode"
when:
- ansible_facts['os_family'] == 'RedHat' and ansible_facts['distribution_major_version']|int < 9
- ansible_facts['os_family'] == 'RedHat'
- ansible_facts['distribution_major_version']|int < 9
- name: Check host key was generated
assert:
@ -47,7 +48,8 @@
- privkey.stat.exists
- pubkey.stat.exists
when:
- ansible_facts['os_family'] == 'RedHat' and ansible_facts['distribution_major_version']|int > 6
- ansible_facts['os_family'] == 'RedHat'
- ansible_facts['distribution_major_version']|int > 6
tags: tests::verify
- name: Fake FIPS mode
@ -122,7 +124,8 @@
- not privkey.stat.exists
- not pubkey.stat.exists
when:
- ansible_facts['os_family'] == 'RedHat' and ansible_facts['distribution_major_version'] in ['7', '8']
- ansible_facts['os_family'] == 'RedHat'
- ansible_facts['distribution_major_version']|int > 6
tags: tests::verify
- name: Remove the FIPS mode indicators