From 473ed03e261d438e6780a92c34f4c2181728e2db Mon Sep 17 00:00:00 2001 From: Thomas Woerner <twoerner@redhat.com> Date: Tue, 20 Dec 2022 13:50:23 +0100 Subject: [PATCH] host*: Use FQCN for ansible.builtin Use Fully Qualified Collection Name (FQCN) for ansible builtins. This is ansible.builtin.set_fact instead of set_fact for example and aplies for all actions that are part of ansible.builtin. All the replaced ansible.builtins: assert, command, copy, debug, fail, fetch, file, import_playbook, import_tasks, include_role, include_tasks, include_vars, package, set_fact, shell, slurp, stat, systemd --- .../host/ensure_host_with_randompassword.yml | 2 +- .../host/host-present-with-randompassword.yml | 2 +- .../host/hosts-present-with-randompasswords.yml | 4 ++-- tests/host/certificate/test_host_certificate.yml | 6 +++--- .../host/certificate/test_hosts_certificate.yml | 6 +++--- tests/host/test_host.yml | 6 +++--- tests/host/test_host_allow_create_keytab.yml | 6 +++--- tests/host/test_host_allow_retrieve_keytab.yml | 6 +++--- tests/host/test_host_bool_params.yml | 4 ++-- tests/host/test_host_client_context.yml | 6 +++--- tests/host/test_host_empty_string_params.yml | 4 ++-- tests/host/test_host_ipaddresses.yml | 6 +++--- tests/host/test_host_managedby_host.yml | 4 ++-- tests/host/test_host_principal.yml | 6 +++--- tests/host/test_host_random.yml | 16 ++++++++-------- tests/host/test_host_reverse.yml | 8 ++++---- tests/host/test_host_sshpubkey.yml | 4 ++-- tests/host/test_hosts.yml | 4 ++-- tests/host/test_hosts_managedby_host.yml | 4 ++-- tests/host/test_hosts_principal.yml | 6 +++--- tests/hostgroup/test_hostgroup.yml | 2 +- .../hostgroup/test_hostgroup_client_context.yml | 6 +++--- tests/hostgroup/test_hostgroup_membermanager.yml | 2 +- tests/hostgroup/test_hostgroup_rename.yml | 2 +- 24 files changed, 61 insertions(+), 61 deletions(-) diff --git a/playbooks/host/ensure_host_with_randompassword.yml b/playbooks/host/ensure_host_with_randompassword.yml index d6376033..6e49e86d 100644 --- a/playbooks/host/ensure_host_with_randompassword.yml +++ b/playbooks/host/ensure_host_with_randompassword.yml @@ -14,5 +14,5 @@ register: ipahost - name: Print generated random password - debug: + ansible.builtin.debug: var: ipahost.host.randompassword diff --git a/playbooks/host/host-present-with-randompassword.yml b/playbooks/host/host-present-with-randompassword.yml index 2e9d793d..d26f2b60 100644 --- a/playbooks/host/host-present-with-randompassword.yml +++ b/playbooks/host/host-present-with-randompassword.yml @@ -13,5 +13,5 @@ register: ipahost - name: Print generated random password - debug: + ansible.builtin.debug: var: ipahost.host.randompassword diff --git a/playbooks/host/hosts-present-with-randompasswords.yml b/playbooks/host/hosts-present-with-randompasswords.yml index 8f330c0d..892fabc4 100644 --- a/playbooks/host/hosts-present-with-randompasswords.yml +++ b/playbooks/host/hosts-present-with-randompasswords.yml @@ -17,9 +17,9 @@ register: ipahost - name: Print generated random password for host01.example.com - debug: + ansible.builtin.debug: var: ipahost.host["host01.example.com"].randompassword - name: Print generated random password for host02.example.com - debug: + ansible.builtin.debug: var: ipahost.host["host02.example.com"].randompassword diff --git a/tests/host/certificate/test_host_certificate.yml b/tests/host/certificate/test_host_certificate.yml index b6357808..62c047e8 100644 --- a/tests/host/certificate/test_host_certificate.yml +++ b/tests/host/certificate/test_host_certificate.yml @@ -5,12 +5,12 @@ tasks: - name: Get Domain from server name - set_fact: + ansible.builtin.set_fact: ipaserver_domain: "{{ ansible_facts['fqdn'].split('.')[1:] | join ('.') }}" when: ipaserver_domain is not defined - name: Generate self-signed certificates. - shell: + ansible.builtin.shell: cmd: | openssl req -x509 -newkey rsa:2048 -days 365 -nodes -keyout "private{{ item }}.key" -out "cert{{ item }}.pem" -subj '/CN=test' openssl x509 -outform der -in "cert{{ item }}.pem" -out "cert{{ item }}.der" @@ -100,7 +100,7 @@ failed_when: result.changed or result.failed - name: Remove certificate files. # noqa: deprecated-command-syntax - shell: + ansible.builtin.shell: cmd: rm -f "private{{ item }}.key" "cert{{ item }}.pem" "cert{{ item }}.der" "cert{{ item }}.b64" with_items: [1, 2, 3] become: no diff --git a/tests/host/certificate/test_hosts_certificate.yml b/tests/host/certificate/test_hosts_certificate.yml index 77f861c0..3e8779b1 100644 --- a/tests/host/certificate/test_hosts_certificate.yml +++ b/tests/host/certificate/test_hosts_certificate.yml @@ -5,7 +5,7 @@ tasks: - name: Get Domain from server name - set_fact: + ansible.builtin.set_fact: ipaserver_domain: "{{ ansible_facts['fqdn'].split('.')[1:] | join ('.') }}" when: ipaserver_domain is not defined @@ -26,7 +26,7 @@ failed_when: not result.changed or result.failed - name: Generate self-signed certificates. - shell: + ansible.builtin.shell: cmd: | openssl req -x509 -newkey rsa:2048 -days 365 -nodes -keyout "private{{ item }}.key" -out "cert{{ item }}.pem" -subj '/CN=test' openssl x509 -outform der -in "cert{{ item }}.pem" -out "cert{{ item }}.der" @@ -99,7 +99,7 @@ failed_when: not result.changed or result.failed - name: Remove certificate files. # noqa: deprecated-command-syntax - shell: + ansible.builtin.shell: cmd: rm -f "private{{ item }}.key" "cert{{ item }}.pem" "cert{{ item }}.der" "cert{{ item }}.b64" with_items: [1, 2, 3] become: no diff --git a/tests/host/test_host.yml b/tests/host/test_host.yml index bee85ef7..ac62b71e 100644 --- a/tests/host/test_host.yml +++ b/tests/host/test_host.yml @@ -5,12 +5,12 @@ tasks: - name: Get Domain from server name - set_fact: + ansible.builtin.set_fact: ipaserver_domain: "{{ ansible_facts['fqdn'].split('.')[1:] | join ('.') }}" when: ipaserver_domain is not defined - name: Set host1_fqdn .. host6_fqdn - set_fact: + ansible.builtin.set_fact: host1_fqdn: "{{ 'host1.' + ipaserver_domain }}" host2_fqdn: "{{ 'host2.' + ipaserver_domain }}" host3_fqdn: "{{ 'host3.' + ipaserver_domain }}" @@ -33,7 +33,7 @@ state: absent - name: Get IPv4 address prefix from server node - set_fact: + ansible.builtin.set_fact: ipv4_prefix: "{{ ansible_facts['default_ipv4'].address.split('.')[:-1] | join('.') }}" diff --git a/tests/host/test_host_allow_create_keytab.yml b/tests/host/test_host_allow_create_keytab.yml index b5242422..ee2da2f6 100644 --- a/tests/host/test_host_allow_create_keytab.yml +++ b/tests/host/test_host_allow_create_keytab.yml @@ -5,17 +5,17 @@ tasks: - name: Get Domain from server name - set_fact: + ansible.builtin.set_fact: ipaserver_domain: "{{ ansible_facts['fqdn'].split('.')[1:] | join ('.') }}" when: ipaserver_domain is not defined - name: Get Realm from server name - set_fact: + ansible.builtin.set_fact: ipaserver_realm: "{{ ansible_facts['fqdn'].split('.')[1:] | join ('.') | upper }}" when: ipaserver_realm is not defined - name: Set host1_fqdn .. host3_fqdn - set_fact: + ansible.builtin.set_fact: host1_fqdn: "{{ 'host1.' + ipaserver_domain }}" host2_fqdn: "{{ 'host2.' + ipaserver_domain }}" host3_fqdn: "{{ 'host3.' + ipaserver_domain }}" diff --git a/tests/host/test_host_allow_retrieve_keytab.yml b/tests/host/test_host_allow_retrieve_keytab.yml index f38ea302..13af3d01 100644 --- a/tests/host/test_host_allow_retrieve_keytab.yml +++ b/tests/host/test_host_allow_retrieve_keytab.yml @@ -5,17 +5,17 @@ tasks: - name: Get Domain from server name - set_fact: + ansible.builtin.set_fact: ipaserver_domain: "{{ ansible_facts['fqdn'].split('.')[1:] | join ('.') }}" when: ipaserver_domain is not defined - name: Get Realm from server name - set_fact: + ansible.builtin.set_fact: ipaserver_realm: "{{ ansible_facts['fqdn'].split('.')[1:] | join ('.') | upper }}" when: ipaserver_realm is not defined - name: Set host1_fqdn .. host3_fqdn - set_fact: + ansible.builtin.set_fact: host1_fqdn: "{{ 'host1.' + ipaserver_domain }}" host2_fqdn: "{{ 'host2.' + ipaserver_domain }}" host3_fqdn: "{{ 'host3.' + ipaserver_domain }}" diff --git a/tests/host/test_host_bool_params.yml b/tests/host/test_host_bool_params.yml index cfb2f653..e5d4dfd0 100644 --- a/tests/host/test_host_bool_params.yml +++ b/tests/host/test_host_bool_params.yml @@ -5,12 +5,12 @@ tasks: - name: Get Domain from server name - set_fact: + ansible.builtin.set_fact: ipaserver_domain: "{{ ansible_facts['fqdn'].split('.')[1:] | join ('.') }}" when: ipaserver_domain is not defined - name: Set host1_fqdn .. host6_fqdn - set_fact: + ansible.builtin.set_fact: host1_fqdn: "{{ 'host1.' + ipaserver_domain }}" - name: Host absent diff --git a/tests/host/test_host_client_context.yml b/tests/host/test_host_client_context.yml index 8afcef32..e36b0925 100644 --- a/tests/host/test_host_client_context.yml +++ b/tests/host/test_host_client_context.yml @@ -6,7 +6,7 @@ tasks: - name: Include FreeIPA facts. - include_tasks: ../env_freeipa_facts.yml + ansible.builtin.include_tasks: ../env_freeipa_facts.yml # Test will only be executed if host is not a server. - name: Execute with server context in the client. @@ -27,13 +27,13 @@ # in upstream CI. - name: Test automember using client context, in client host. - import_playbook: test_host.yml + ansible.builtin.import_playbook: test_host.yml when: groups['ipaclients'] vars: ipa_test_host: ipaclients - name: Test automember using client context, in server host. - import_playbook: test_host.yml + ansible.builtin.import_playbook: test_host.yml when: groups['ipaclients'] is not defined or not groups['ipaclients'] vars: ipa_context: client diff --git a/tests/host/test_host_empty_string_params.yml b/tests/host/test_host_empty_string_params.yml index 59481d11..1103b0f8 100644 --- a/tests/host/test_host_empty_string_params.yml +++ b/tests/host/test_host_empty_string_params.yml @@ -6,12 +6,12 @@ tasks: - name: Get Domain from server name - set_fact: + ansible.builtin.set_fact: ipaserver_domain: "{{ ansible_facts['fqdn'].split('.')[1:] | join ('.') }}" when: ipaserver_domain is not defined - name: Set host1_fqdn .. host6_fqdn - set_fact: + ansible.builtin.set_fact: host1_fqdn: "{{ 'host1.' + ipaserver_domain }}" # CLEANUP TEST ITEMS diff --git a/tests/host/test_host_ipaddresses.yml b/tests/host/test_host_ipaddresses.yml index 9ff9a090..e8591617 100644 --- a/tests/host/test_host_ipaddresses.yml +++ b/tests/host/test_host_ipaddresses.yml @@ -5,18 +5,18 @@ tasks: - name: Get Domain from server name - set_fact: + ansible.builtin.set_fact: ipaserver_domain: "{{ ansible_facts['fqdn'].split('.')[1:] | join ('.') }}" when: ipaserver_domain is not defined - name: Set host1_fqdn .. host6_fqdn - set_fact: + ansible.builtin.set_fact: host1_fqdn: "{{ 'host1.' + ipaserver_domain }}" host2_fqdn: "{{ 'host2.' + ipaserver_domain }}" host3_fqdn: "{{ 'host3.' + ipaserver_domain }}" - name: Get IPv4 address prefix from server node - set_fact: + ansible.builtin.set_fact: ipv4_prefix: "{{ ansible_facts['default_ipv4'].address.split('.')[:-1] | join('.') }}" diff --git a/tests/host/test_host_managedby_host.yml b/tests/host/test_host_managedby_host.yml index a96b674f..36551d02 100644 --- a/tests/host/test_host_managedby_host.yml +++ b/tests/host/test_host_managedby_host.yml @@ -5,12 +5,12 @@ tasks: - name: Get Domain from server name - set_fact: + ansible.builtin.set_fact: ipaserver_domain: "{{ ansible_facts['fqdn'].split('.')[1:] | join ('.') }}" when: ipaserver_domain is not defined - name: Set host1_fqdn .. host2_fqdn - set_fact: + ansible.builtin.set_fact: host1_fqdn: "{{ 'host1.' + ipaserver_domain }}" host2_fqdn: "{{ 'host2.' + ipaserver_domain }}" diff --git a/tests/host/test_host_principal.yml b/tests/host/test_host_principal.yml index 7dcbc42c..1f6dbb15 100644 --- a/tests/host/test_host_principal.yml +++ b/tests/host/test_host_principal.yml @@ -5,17 +5,17 @@ tasks: - name: Get Domain from server name - set_fact: + ansible.builtin.set_fact: ipaserver_domain: "{{ ansible_facts['fqdn'].split('.')[1:] | join ('.') }}" when: ipaserver_domain is not defined - name: Get Realm from server name - set_fact: + ansible.builtin.set_fact: ipaserver_realm: "{{ ansible_facts['fqdn'].split('.')[1:] | join ('.') | upper }}" when: ipaserver_realm is not defined - name: Set host1_fqdn - set_fact: + ansible.builtin.set_fact: host1_fqdn: "{{ 'host1.' + ipaserver_domain }}" - name: Host host1 absent diff --git a/tests/host/test_host_random.yml b/tests/host/test_host_random.yml index 8b9a2c08..1f49b43e 100644 --- a/tests/host/test_host_random.yml +++ b/tests/host/test_host_random.yml @@ -5,12 +5,12 @@ tasks: - name: Get Domain from server name - set_fact: + ansible.builtin.set_fact: ipaserver_domain: "{{ ansible_facts['fqdn'].split('.')[1:] | join ('.') }}" when: ipaserver_domain is not defined - name: Set host1_fqdn and host2_fqdn - set_fact: + ansible.builtin.set_fact: host1_fqdn: "{{ 'host1.' + ipaserver_domain }}" host2_fqdn: "{{ 'host2.' + ipaserver_domain }}" @@ -34,12 +34,12 @@ failed_when: not ipahost.changed or ipahost.failed - name: Assert ipahost.host.randompassword is defined. - assert: + ansible.builtin.assert: that: - ipahost.host.randompassword is defined - name: Print generated random password - debug: + ansible.builtin.debug: var: ipahost.host.randompassword - name: Host "{{ host1_fqdn }}" absent @@ -64,7 +64,7 @@ failed_when: not ipahost.changed or ipahost.failed - name: Assert randompassword is defined for host1 and host2. - assert: + ansible.builtin.assert: that: - ipahost.host["{{ host1_fqdn }}"].randompassword is defined @@ -72,11 +72,11 @@ defined - name: Print generated random password for "{{ host1_fqdn }}" - debug: + ansible.builtin.debug: var: ipahost.host["{{ host1_fqdn }}"].randompassword - name: Print generated random password for "{{ host2_fqdn }}" - debug: + ansible.builtin.debug: var: ipahost.host["{{ host2_fqdn }}"].randompassword - name: Enrolled host "{{ ansible_facts['fqdn'] }}" fails to set random password with update_password always @@ -90,7 +90,7 @@ failed_when: ipahost.changed or not ipahost.failed - name: Assert randompassword is not defined for 'ansible_fqdn'. - assert: + ansible.builtin.assert: that: - ipahost.host["{{ ansible_facts['fqdn'] }}"].randompassword is not defined diff --git a/tests/host/test_host_reverse.yml b/tests/host/test_host_reverse.yml index 8e5e337e..27c64328 100644 --- a/tests/host/test_host_reverse.yml +++ b/tests/host/test_host_reverse.yml @@ -5,12 +5,12 @@ tasks: - name: Get Domain from server name - set_fact: + ansible.builtin.set_fact: ipaserver_domain: "{{ ansible_facts['fqdn'].split('.')[1:] | join ('.') }}" when: ipaserver_domain is not defined - name: Set host1_fqdn - set_fact: + ansible.builtin.set_fact: host1_fqdn: "{{ 'host1.' + ipaserver_domain }}" - name: Host absent @@ -22,12 +22,12 @@ state: absent - name: Get IPv4 address prefix from server node - set_fact: + ansible.builtin.set_fact: ipv4_prefix: "{{ ansible_facts['default_ipv4'].address.split('.')[:-1] | join('.') }}" - name: Set zone prefixes. - set_fact: + ansible.builtin.set_fact: zone_ipv6_reverse: "ip6.arpa." zone_ipv6_reverse_workaround: "d.f.ip6.arpa." zone_prefix_reverse: "in-addr.arpa" diff --git a/tests/host/test_host_sshpubkey.yml b/tests/host/test_host_sshpubkey.yml index c9c79fd6..7bf0da16 100644 --- a/tests/host/test_host_sshpubkey.yml +++ b/tests/host/test_host_sshpubkey.yml @@ -5,12 +5,12 @@ tasks: - name: Get Domain from server name - set_fact: + ansible.builtin.set_fact: ipaserver_domain: "{{ ansible_facts['fqdn'].split('.')[1:] | join ('.') }}" when: ipaserver_domain is not defined - name: Set host1_fqdn - set_fact: + ansible.builtin.set_fact: host1_fqdn: "{{ 'host1.' + ipaserver_domain }}" - name: Host host1 absent diff --git a/tests/host/test_hosts.yml b/tests/host/test_hosts.yml index 53e3b092..d462bd47 100644 --- a/tests/host/test_hosts.yml +++ b/tests/host/test_hosts.yml @@ -5,12 +5,12 @@ tasks: - name: Get Domain from server name - set_fact: + ansible.builtin.set_fact: ipaserver_domain: "{{ ansible_facts['fqdn'].split('.')[1:] | join ('.') }}" when: ipaserver_domain is not defined - name: Set host1_fqdn .. host6_fqdn - set_fact: + ansible.builtin.set_fact: host1_fqdn: "{{ 'host1.' + ipaserver_domain }}" host2_fqdn: "{{ 'host2.' + ipaserver_domain }}" host3_fqdn: "{{ 'host3.' + ipaserver_domain }}" diff --git a/tests/host/test_hosts_managedby_host.yml b/tests/host/test_hosts_managedby_host.yml index 51d7272c..ec0208a5 100644 --- a/tests/host/test_hosts_managedby_host.yml +++ b/tests/host/test_hosts_managedby_host.yml @@ -5,12 +5,12 @@ tasks: - name: Get Domain from server name - set_fact: + ansible.builtin.set_fact: ipaserver_domain: "{{ ansible_facts['fqdn'].split('.')[1:] | join ('.') }}" when: ipaserver_domain is not defined - name: Set host1_fqdn .. host5_fqdn - set_fact: + ansible.builtin.set_fact: host1_fqdn: "{{ 'host1.' + ipaserver_domain }}" host2_fqdn: "{{ 'host2.' + ipaserver_domain }}" host3_fqdn: "{{ 'host3.' + ipaserver_domain }}" diff --git a/tests/host/test_hosts_principal.yml b/tests/host/test_hosts_principal.yml index 973afdc4..77fee9e3 100644 --- a/tests/host/test_hosts_principal.yml +++ b/tests/host/test_hosts_principal.yml @@ -5,17 +5,17 @@ tasks: - name: Get Domain from server name - set_fact: + ansible.builtin.set_fact: ipaserver_domain: "{{ ansible_facts['fqdn'].split('.')[1:] | join ('.') }}" when: ipaserver_domain is not defined - name: Get Realm from server name - set_fact: + ansible.builtin.set_fact: ipaserver_realm: "{{ ansible_facts['fqdn'].split('.')[1:] | join ('.') | upper }}" when: ipaserver_realm is not defined - name: Set host1_fqdn .. host2_fqdn - set_fact: + ansible.builtin.set_fact: host1_fqdn: "{{ 'host1.' + ipaserver_domain }}" host2_fqdn: "{{ 'host2.' + ipaserver_domain }}" diff --git a/tests/hostgroup/test_hostgroup.yml b/tests/hostgroup/test_hostgroup.yml index d8a7305d..b667d56a 100644 --- a/tests/hostgroup/test_hostgroup.yml +++ b/tests/hostgroup/test_hostgroup.yml @@ -6,7 +6,7 @@ tasks: - name: Get Domain from server name - set_fact: + ansible.builtin.set_fact: ipaserver_domain: "{{ ansible_facts['fqdn'].split('.')[1:] | join ('.') }}" when: ipaserver_domain is not defined diff --git a/tests/hostgroup/test_hostgroup_client_context.yml b/tests/hostgroup/test_hostgroup_client_context.yml index c412d31b..12756546 100644 --- a/tests/hostgroup/test_hostgroup_client_context.yml +++ b/tests/hostgroup/test_hostgroup_client_context.yml @@ -6,7 +6,7 @@ tasks: - name: Include FreeIPA facts. - include_tasks: ../env_freeipa_facts.yml + ansible.builtin.include_tasks: ../env_freeipa_facts.yml # Test will only be executed if host is not a server. - name: Execute with server context in the client. @@ -27,13 +27,13 @@ # in upstream CI. - name: Test hostgroup using client context, in client host. - import_playbook: test_hostgroup.yml + ansible.builtin.import_playbook: test_hostgroup.yml when: groups['ipaclients'] vars: ipa_test_host: ipaclients - name: Test hostgroup using client context, in server host. - import_playbook: test_hostgroup.yml + ansible.builtin.import_playbook: test_hostgroup.yml when: groups['ipaclients'] is not defined or not groups['ipaclients'] vars: ipa_context: client diff --git a/tests/hostgroup/test_hostgroup_membermanager.yml b/tests/hostgroup/test_hostgroup_membermanager.yml index ff8adc87..9005cd51 100644 --- a/tests/hostgroup/test_hostgroup_membermanager.yml +++ b/tests/hostgroup/test_hostgroup_membermanager.yml @@ -5,7 +5,7 @@ gather_facts: false tasks: - - include_tasks: ../env_freeipa_facts.yml + - ansible.builtin.include_tasks: ../env_freeipa_facts.yml - name: Tests requiring IPA version 4.8.4+ block: diff --git a/tests/hostgroup/test_hostgroup_rename.yml b/tests/hostgroup/test_hostgroup_rename.yml index d3dd33b2..d0321796 100644 --- a/tests/hostgroup/test_hostgroup_rename.yml +++ b/tests/hostgroup/test_hostgroup_rename.yml @@ -5,7 +5,7 @@ gather_facts: false tasks: - - include_tasks: ../env_freeipa_facts.yml + - ansible.builtin.include_tasks: ../env_freeipa_facts.yml - name: Tests requiring IPA version 4.8.7+ block: -- GitLab