diff --git a/roles/backup/molecule/default/prepare.yml b/roles/backup/molecule/default/prepare.yml index fddd69fd2ab07db6f95b7553fa4c7a0431ebd22c..eefd77c3d02929d5fe3bed6cc81072fdb26e7060 100644 --- a/roles/backup/molecule/default/prepare.yml +++ b/roles/backup/molecule/default/prepare.yml @@ -2,17 +2,14 @@ - name: Prepare hosts: all + become: true gather_facts: false tasks: + - name: Install python for Ansible raw: test -e /usr/bin/python3 || (apt -y update && apt install -y python3-minimal) - become: true changed_when: false -- hosts: all - become: true - tasks: - - name: Update all caches to avoid errors due to missing remote archives apt: update_cache: true diff --git a/roles/backup_client/molecule/default/prepare.yml b/roles/backup_client/molecule/default/prepare.yml index 4976ea4c11f8a03203e5789d970ef439193d1256..b9c64c0164bc2770650c363c7a852a97b48f6b1d 100644 --- a/roles/backup_client/molecule/default/prepare.yml +++ b/roles/backup_client/molecule/default/prepare.yml @@ -2,23 +2,21 @@ - name: Prepare hosts: all + become: true gather_facts: false tasks: + - name: Install python for Ansible raw: test -e /usr/bin/python3 || (apt -y update && apt install -y python3-minimal) - become: true changed_when: false -- hosts: all - become: true - tasks: - - name: Update all caches to avoid errors due to missing remote archives apt: update_cache: true changed_when: false -- hosts: backup-server +- name: Prepare, helpers + hosts: backup-server become: true tasks: diff --git a/roles/backup_server/molecule/default/prepare.yml b/roles/backup_server/molecule/default/prepare.yml index 85d51d2ea5b4f1aac00053e50d0a4a2dfb2bfb8b..d5df27dc533f1e55e4f81dfdc20b703950416bd9 100644 --- a/roles/backup_server/molecule/default/prepare.yml +++ b/roles/backup_server/molecule/default/prepare.yml @@ -1,11 +1,7 @@ --- -- name: Prepare - hosts: all - gather_facts: false - tasks: - -- hosts: localhost +- name: Prepare, test fixtures + hosts: localhost connection: local tasks: @@ -17,13 +13,14 @@ - tests/data/ssh/client1 - tests/data/ssh/client2 -- hosts: all +- name: Prepare + hosts: all become: true + gather_facts: false tasks: - name: Install python for Ansible raw: test -e /usr/bin/python3 || (apt -y update && apt install -y python3-minimal) - become: true changed_when: false - name: Update all caches to avoid errors due to missing remote archives diff --git a/roles/bootstrap/molecule/default/prepare.yml b/roles/bootstrap/molecule/default/prepare.yml index f03d4f5d4175634a32df11c26577179983e34278..7f1c268a76b571a1cedb0cf1578a7267ac17c11e 100644 --- a/roles/bootstrap/molecule/default/prepare.yml +++ b/roles/bootstrap/molecule/default/prepare.yml @@ -2,15 +2,22 @@ - name: Prepare hosts: all + become: true gather_facts: false tasks: + - name: Install python for Ansible raw: test -e /usr/bin/python3 || (apt -y update && apt install -y python3-minimal) - become: true + changed_when: false + + - name: Update all caches to avoid errors due to missing remote archives + apt: + update_cache: true changed_when: false # Put Ansible key into root's authorized_keys to test its removal. -- hosts: parameters-mandatory +- name: Prepare, text fixtures + hosts: parameters-mandatory become: true tasks: @@ -20,7 +27,8 @@ key: "{{ lookup('file', '~/.ssh/id_rsa.pub') }}" # Put Ansible key into root's authorized_keys to test its removal. -- hosts: parameters-optional +- name: Prepare, text fixtures + hosts: parameters-optional become: true tasks: diff --git a/roles/common/molecule/default/prepare.yml b/roles/common/molecule/default/prepare.yml index c205858aedc3818f36d4ff1752b6c1826cf659d1..89d70e19002bf8f9524d57712ff0258eee9ad6ed 100644 --- a/roles/common/molecule/default/prepare.yml +++ b/roles/common/molecule/default/prepare.yml @@ -1,6 +1,6 @@ --- -- name: Set-up fixtures +- name: Prepare, test fixtures hosts: localhost connection: local gather_facts: false @@ -20,18 +20,14 @@ - name: Prepare hosts: all + become: true gather_facts: false tasks: - name: Install python for Ansible raw: test -e /usr/bin/python3 || (apt -y update && apt install -y python3-minimal) - become: true changed_when: false -- hosts: all - become: true - tasks: - - name: Update all caches to avoid errors due to missing remote archives apt: update_cache: true @@ -42,7 +38,13 @@ name: net-tools state: present -- hosts: helper + - name: Remove the ss utility (see https://github.com/philpep/testinfra/pull/320) + file: + path: "/bin/ss" + state: absent + +- name: Prepare, helpers + hosts: helper become: true tasks: @@ -51,7 +53,8 @@ name: apt-cacher-ng state: present -- hosts: client +- name: Prepare, helpers + hosts: client become: true tasks: @@ -75,7 +78,8 @@ fd00::192:168:56:21: parameters-mandatory-bookworm fd00::192:168:56:22: parameters-optional-bookworm -- hosts: parameters-mandatory,parameters-optional +- name: Prepare, test fixtures + hosts: parameters-mandatory,parameters-optional become: true tasks: @@ -156,12 +160,3 @@ - ntp - ntpdate state: present - -- hosts: parameters-mandatory,parameters-optional - become: true - tasks: - - - name: Remove the ss utility (see https://github.com/philpep/testinfra/pull/320) - file: - path: "/bin/ss" - state: absent diff --git a/roles/database/molecule/default/prepare.yml b/roles/database/molecule/default/prepare.yml index b4d51db5d50ce0fd8a491efb1e31659a15585e02..b89a35b8ff052860e49c4e0d1048cdaae3d271bd 100644 --- a/roles/database/molecule/default/prepare.yml +++ b/roles/database/molecule/default/prepare.yml @@ -2,23 +2,21 @@ - name: Prepare hosts: all + become: true gather_facts: false tasks: + - name: Install python for Ansible raw: test -e /usr/bin/python3 || (apt -y update && apt install -y python3-minimal) - become: true changed_when: false -- hosts: all - become: true - tasks: - - name: Update all caches to avoid errors due to missing remote archives apt: update_cache: true changed_when: false -- hosts: backup-server +- name: Prepare, helpers + hosts: backup-server become: true roles: - role: backup_server diff --git a/roles/database_server/molecule/default/prepare.yml b/roles/database_server/molecule/default/prepare.yml index fddd69fd2ab07db6f95b7553fa4c7a0431ebd22c..eefd77c3d02929d5fe3bed6cc81072fdb26e7060 100644 --- a/roles/database_server/molecule/default/prepare.yml +++ b/roles/database_server/molecule/default/prepare.yml @@ -2,17 +2,14 @@ - name: Prepare hosts: all + become: true gather_facts: false tasks: + - name: Install python for Ansible raw: test -e /usr/bin/python3 || (apt -y update && apt install -y python3-minimal) - become: true changed_when: false -- hosts: all - become: true - tasks: - - name: Update all caches to avoid errors due to missing remote archives apt: update_cache: true diff --git a/roles/ldap_client/handlers/main.yml b/roles/ldap_client/handlers/main.yml index 95f29b7a2a9f22adce44f88731d56b24b1723de4..8dae2fd6fcd7ea5173f2e61f1ea32b955134ba09 100644 --- a/roles/ldap_client/handlers/main.yml +++ b/roles/ldap_client/handlers/main.yml @@ -1,4 +1,5 @@ --- -- debug: - msg: "No handlers are available for ldap_client role." +- name: Dummy handler to suppress Ansible warnings + debug: + msg: "This is just a dummy task to suppress the Ansible warning about an empty include." diff --git a/roles/ldap_client/molecule/default/prepare.yml b/roles/ldap_client/molecule/default/prepare.yml index fddd69fd2ab07db6f95b7553fa4c7a0431ebd22c..eefd77c3d02929d5fe3bed6cc81072fdb26e7060 100644 --- a/roles/ldap_client/molecule/default/prepare.yml +++ b/roles/ldap_client/molecule/default/prepare.yml @@ -2,17 +2,14 @@ - name: Prepare hosts: all + become: true gather_facts: false tasks: + - name: Install python for Ansible raw: test -e /usr/bin/python3 || (apt -y update && apt install -y python3-minimal) - become: true changed_when: false -- hosts: all - become: true - tasks: - - name: Update all caches to avoid errors due to missing remote archives apt: update_cache: true diff --git a/roles/ldap_server/molecule/default/prepare.yml b/roles/ldap_server/molecule/default/prepare.yml index b8fe70ad6d3b51be79b68e000cec88983b673e5b..f39aa74bc1ae8d161c37032696a92716e05b7f75 100644 --- a/roles/ldap_server/molecule/default/prepare.yml +++ b/roles/ldap_server/molecule/default/prepare.yml @@ -1,6 +1,6 @@ --- -- name: Set-up fixtures +- name: Prepare, test fixtures hosts: localhost connection: local gather_facts: false @@ -36,17 +36,14 @@ - name: Prepare hosts: all + become: true gather_facts: false tasks: + - name: Install python for Ansible raw: test -e /usr/bin/python3 || (apt -y update && apt install -y python3-minimal) - become: true changed_when: false -- hosts: all - become: true - tasks: - - name: Update all caches to avoid errors due to missing remote archives apt: update_cache: true @@ -60,7 +57,21 @@ group: root mode: 0644 -- hosts: client + - name: Remove the ss utility (see https://github.com/philpep/testinfra/pull/320) + file: + path: "/bin/ss" + state: absent + + - name: Install tools for testing + apt: + name: + - net-tools + - nmap + - gnutls-bin + state: present + +- name: Prepare, helpers + hosts: client become: true tasks: @@ -82,7 +93,8 @@ 192.168.56.21: parameters-mandatory-bookworm 192.168.56.22: parameters-optional-bookworm -- hosts: parameters-optional +- name: Prepare, test fixtures + hosts: parameters-optional become: true tasks: @@ -98,7 +110,8 @@ with_dict: 127.0.2.1: parameters-optional -- hosts: parameters-mandatory +- name: Prepare, test fixtures + hosts: parameters-mandatory become: true tasks: @@ -114,7 +127,8 @@ with_dict: 127.0.2.1: parameters-mandatory -- hosts: backup-server +- name: Prepare, helpers + hosts: backup-server become: true roles: - role: backup_server @@ -126,20 +140,3 @@ - server: localhost ip: 127.0.0.1 public_key: "{{ lookup('file', 'tests/data/ssh/parameters-optional.pub') }}" - -- hosts: parameters-mandatory,parameters-optional - become: true - tasks: - - - name: Remove the ss utility (see https://github.com/philpep/testinfra/pull/320) - file: - path: "/bin/ss" - state: absent - - - name: Install tools for testing - apt: - name: - - net-tools - - nmap - - gnutls-bin - state: present diff --git a/roles/mail_forwarder/molecule/default/prepare.yml b/roles/mail_forwarder/molecule/default/prepare.yml index 9ed70c614048a8fd9ee502f314f38b31e39ed8f6..1d54b9fd723b49a1719b966263953741e2b30b7e 100644 --- a/roles/mail_forwarder/molecule/default/prepare.yml +++ b/roles/mail_forwarder/molecule/default/prepare.yml @@ -1,6 +1,6 @@ --- -- name: Set-up fixtures +- name: Prepare, test fixtures hosts: localhost connection: local gather_facts: false @@ -34,26 +34,19 @@ - name: Prepare hosts: all + become: true gather_facts: false tasks: + - name: Install python for Ansible raw: test -e /usr/bin/python3 || (apt -y update && apt install -y python3-minimal) - become: true changed_when: false -- hosts: all - become: true - tasks: - - name: Update all caches to avoid errors due to missing remote archives apt: update_cache: true changed_when: false -- hosts: all - become: true - tasks: - - name: Set-up the hosts file lineinfile: path: /etc/hosts @@ -75,7 +68,8 @@ name: gnutls-bin state: present -- hosts: clients +- name: Prepare, helpers + hosts: clients become: true tasks: @@ -104,7 +98,8 @@ - name: Update CA certificate cache command: /usr/sbin/update-ca-certificates --fresh -- hosts: mail-servers +- name: Prepare, helpers + hosts: mail-servers become: true tasks: @@ -174,7 +169,8 @@ name: postfix state: restarted -- hosts: parameters-optional +- name: Prepare, test fixtures + hosts: parameters-optional become: true tasks: diff --git a/roles/mail_server/molecule/default/prepare.yml b/roles/mail_server/molecule/default/prepare.yml index 93303a1c894c75abdf229df8e4b3b94c7e02d6ba..ba20de4155ccf89dfe2968713614d3cbabda07a2 100644 --- a/roles/mail_server/molecule/default/prepare.yml +++ b/roles/mail_server/molecule/default/prepare.yml @@ -1,6 +1,6 @@ --- -- name: Set-up fixtures +- name: Prepare, test fixtures hosts: localhost connection: local gather_facts: false @@ -46,17 +46,13 @@ - name: Prepare hosts: all + become: true gather_facts: false tasks: - name: Install python for Ansible raw: test -e /usr/bin/python3 || (apt -y update && apt install -y python3-minimal) - become: true changed_when: false -- hosts: all - become: true - tasks: - - name: Update all caches to avoid errors due to missing remote archives apt: update_cache: true @@ -69,7 +65,7 @@ - nmap state: present -- name: Set-up a local ClamAV database mirror to avoid hitting upstream rate limits +- name: Prepare, helpers, local ClamAV database mirror (avoid upstream rate limits) hosts: clamav-database become: true tasks: @@ -173,7 +169,8 @@ name: nginx state: restarted -- hosts: bookworm +- name: Prepare, test fixtures + hosts: bookworm become: true tasks: @@ -213,7 +210,8 @@ 192.168.56.31: "parameters-mandatory parameters-mandatory-bookworm" 192.168.56.32: "parameters-optional parameters-optional-bookworm" -- hosts: client +- name: Prepare, helpers + hosts: client become: true tasks: @@ -336,13 +334,15 @@ name: postfix state: restarted -- hosts: ldap-server +- name: Prepare, helpers + hosts: ldap-server become: true roles: - ldap_server - backup_server -- hosts: ldap-server +- name: Prepare, test fixtures + hosts: ldap-server become: true tasks: @@ -420,7 +420,8 @@ - uid=john,ou=people,dc=local - uid=jane,ou=people,dc=local -- hosts: parameters-mandatory,parameters-optional +- name: Prepare, test fixtures + hosts: parameters-mandatory,parameters-optional become: true tasks: diff --git a/roles/php_website/molecule/default/prepare.yml b/roles/php_website/molecule/default/prepare.yml index 8e6bf3dd17750b7d5fcb4e16eed0cb4007d142d0..7c284cf492336ff3983e3f2e031525b7e6edb44b 100644 --- a/roles/php_website/molecule/default/prepare.yml +++ b/roles/php_website/molecule/default/prepare.yml @@ -1,6 +1,6 @@ --- -- name: Set-up fixtures +- name: Prepare, test fixtures hosts: localhost connection: local gather_facts: false @@ -38,17 +38,15 @@ - name: Prepare hosts: all + become: true gather_facts: false tasks: + - name: Install python for Ansible raw: test -e /usr/bin/python3 || (apt -y update && apt install -y python3-minimal) become: true changed_when: false -- hosts: all - become: true - tasks: - - name: Update all caches to avoid errors due to missing remote archives apt: update_cache: true diff --git a/roles/preseed/molecule/default/prepare.yml b/roles/preseed/molecule/default/prepare.yml index 058ffa32bc51b8303ffe67c7dad6ff72ec09d41e..eefd77c3d02929d5fe3bed6cc81072fdb26e7060 100644 --- a/roles/preseed/molecule/default/prepare.yml +++ b/roles/preseed/molecule/default/prepare.yml @@ -2,9 +2,15 @@ - name: Prepare hosts: all + become: true gather_facts: false tasks: + - name: Install python for Ansible raw: test -e /usr/bin/python3 || (apt -y update && apt install -y python3-minimal) - become: true + changed_when: false + + - name: Update all caches to avoid errors due to missing remote archives + apt: + update_cache: true changed_when: false diff --git a/roles/web_server/molecule/default/prepare.yml b/roles/web_server/molecule/default/prepare.yml index 90e28a280cd84ee3834bfebc24d5eb9d3a698e99..4b6039e3e89142d7773bd011e505ec30662c2cc4 100644 --- a/roles/web_server/molecule/default/prepare.yml +++ b/roles/web_server/molecule/default/prepare.yml @@ -1,6 +1,6 @@ --- -- name: Set-up fixtures +- name: Prepare, test fixtures hosts: localhost connection: local gather_facts: false @@ -36,17 +36,14 @@ - name: Prepare hosts: all + become: true gather_facts: false tasks: + - name: Install python for Ansible raw: test -e /usr/bin/python3 || (apt -y update && apt install -y python3-minimal) - become: true changed_when: false -- hosts: all - become: true - tasks: - - name: Update all caches to avoid errors due to missing remote archives apt: update_cache: true @@ -59,7 +56,8 @@ - nmap state: present -- hosts: bookworm +- name: Prepare, test fixtures + hosts: bookworm become: true tasks: @@ -81,7 +79,8 @@ mode: 0644 state: present -- hosts: all +- name: Prepare, test fixtures + hosts: all become: true tasks: @@ -104,7 +103,8 @@ name: curl state: present -- hosts: client +- name: Prepare, helpers + hosts: client become: true tasks: diff --git a/roles/wsgi_website/molecule/default/prepare.yml b/roles/wsgi_website/molecule/default/prepare.yml index 8ce1940a144d63a9a2d8b7f91149abae6b878fbf..576b25f7ade46c2e578b0f3fb24e3828f5af047a 100644 --- a/roles/wsgi_website/molecule/default/prepare.yml +++ b/roles/wsgi_website/molecule/default/prepare.yml @@ -1,6 +1,6 @@ --- -- name: Set-up fixtures +- name: Prepare, test fixtures hosts: localhost connection: local gather_facts: false @@ -40,22 +40,29 @@ - name: Prepare hosts: all + become: true gather_facts: false tasks: + - name: Install python for Ansible raw: test -e /usr/bin/python3 || (apt -y update && apt install -y python3-minimal) - become: true changed_when: false -- hosts: wsgi-website - become: true - tasks: - - name: Update all caches to avoid errors due to missing remote archives apt: update_cache: true changed_when: false + - name: Remove the ss utility (see https://github.com/philpep/testinfra/pull/320) + file: + path: "/bin/ss" + state: absent + +- name: Prepare, test fixtures + hosts: wsgi-website + become: true + tasks: + - name: Set-up /etc/hosts entries lineinfile: dest: /etc/hosts @@ -118,11 +125,6 @@ group: user shell: /bin/bash - - name: Remove the ss utility (see https://github.com/philpep/testinfra/pull/320) - file: - path: "/bin/ss" - state: absent - handlers: - name: Restart Postfix diff --git a/roles/xmpp_server/molecule/default/prepare.yml b/roles/xmpp_server/molecule/default/prepare.yml index 1111e787c5fe75f0d7b8106cfc3cc64de42e3989..9a18e4048d553a8d0dc0cd80983793ef418faf6a 100644 --- a/roles/xmpp_server/molecule/default/prepare.yml +++ b/roles/xmpp_server/molecule/default/prepare.yml @@ -1,6 +1,6 @@ --- -- name: Set-up fixtures +- name: Prepare, test fixtures hosts: localhost connection: local gather_facts: false @@ -47,17 +47,15 @@ - name: Prepare hosts: all + become: true gather_facts: false tasks: + - name: Install python for Ansible raw: test -e /usr/bin/python3 || (apt -y update && apt install -y python3-minimal) become: true changed_when: false -- hosts: all - become: true - tasks: - - name: Update all caches to avoid errors due to missing remote archives apt: update_cache: true @@ -76,7 +74,8 @@ regexp: "host\\.name\\)" replace: "host.targetname)" -- hosts: bookworm +- name: Prepare, test fixtures + hosts: bookworm become: true tasks: @@ -113,7 +112,8 @@ 192.168.56.31: "parameters-mandatory domain1 proxy.domain1 conference.domain1" 192.168.56.32: "parameters-optional domain2 proxy.domain2 conference.domain2 domain3 proxy.domain3 conference.domain3" -- hosts: clients +- name: Prepare, helpers + hosts: clients become: true tasks: @@ -187,13 +187,15 @@ - name: Update CA certificate cache command: /usr/sbin/update-ca-certificates --fresh -- hosts: ldap-server +- name: Prepare, helpers + hosts: ldap-server become: true roles: - ldap_server - backup_server -- hosts: ldap-server +- name: Prepare, test fixtures + hosts: ldap-server become: true tasks: @@ -258,7 +260,8 @@ - uid=mick,ou=people,dc=local - uid=eve,ou=people,dc=local -- hosts: parameters-mandatory,parameters-optional +- name: Prepare, test fixtures + hosts: parameters-mandatory,parameters-optional become: true tasks: