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: /etc/ssh/sshd_config.d/00-ansible_system_role.conf
main_sshd_config_name: 00-ansible_system_role.conf main_sshd_config_name: 00-ansible_system_role.conf
main_sshd_config_path: /etc/ssh/sshd_config.d/ main_sshd_config_path: /etc/ssh/sshd_config.d/
when: > when:
ansible_facts['os_family'] == 'RedHat' and - ansible_facts['os_family'] == 'RedHat'
ansible_facts['distribution_major_version']|int > 8 - 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 yes')"
- "config.content | b64decode | regex_search('Match address \\*\\s*PasswordAuthentication no')" - "config.content | b64decode | regex_search('Match address \\*\\s*PasswordAuthentication no')"
when: 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 - name: Check content of configuration file
assert: assert:

View file

@ -39,7 +39,8 @@
that: that:
- "'HostKey /etc/ssh/ssh_host_ed25519_key' in config.content | b64decode" - "'HostKey /etc/ssh/ssh_host_ed25519_key' in config.content | b64decode"
when: 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 - name: Check host key was generated
assert: assert:
@ -47,7 +48,8 @@
- privkey.stat.exists - privkey.stat.exists
- pubkey.stat.exists - pubkey.stat.exists
when: 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 tags: tests::verify
- name: Fake FIPS mode - name: Fake FIPS mode
@ -122,7 +124,8 @@
- not privkey.stat.exists - not privkey.stat.exists
- not pubkey.stat.exists - not pubkey.stat.exists
when: 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 tags: tests::verify
- name: Remove the FIPS mode indicators - name: Remove the FIPS mode indicators