service: 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
This commit is contained in:
Thomas Woerner
2022-12-20 13:53:43 +01:00
parent d204b6d480
commit a9257e7f44
8 changed files with 30 additions and 30 deletions

View File

@@ -6,7 +6,7 @@
tasks:
# setup
- 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"
@@ -16,17 +16,17 @@
delegate_to: localhost
- 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 IPv4 address prefix from server node
set_fact:
ansible.builtin.set_fact:
ipv4_prefix: "{{ ansible_facts['default_ipv4'].address.split('.')[:-1] |
join('.') }}"
- name: Set test host FQDN
set_fact:
ansible.builtin.set_fact:
test_subdomain: testcert
test_host: "{{ 'testcert.' + ipaserver_domain }}"
@@ -215,7 +215,7 @@
state: absent
- 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]
become: no

View File

@@ -1,11 +1,11 @@
# Setup environment for service module tests.
---
- name: Setup variables and facts.
include_tasks: env_vars.yml
ansible.builtin.include_tasks: env_vars.yml
# Cleanup before setup.
- name: Cleanup test environment.
include_tasks: env_cleanup.yml
ansible.builtin.include_tasks: env_cleanup.yml
- name: Add IP address for "nohost" host.
ipadnsrecord:

View File

@@ -1,15 +1,15 @@
---
- name: Get Domain from server name
set_fact:
ansible.builtin.set_fact:
test_domain: "{{ ansible_facts['fqdn'].split('.')[1:] | join('.') }}"
- name: Set host1, host2 and svc hosts fqdn
set_fact:
ansible.builtin.set_fact:
host1_fqdn: "{{ 'host1.' + test_domain }}"
host2_fqdn: "{{ 'host2.' + test_domain }}"
svc_fqdn: "{{ 'svc.' + test_domain }}"
nohost_fqdn: "{{ 'nohost.' + test_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('.') }}"

View File

@@ -17,13 +17,13 @@
tasks:
# setup
- include_tasks: ../env_freeipa_facts.yml
- ansible.builtin.include_tasks: ../env_freeipa_facts.yml
# tests
- name: Tests with skip_host_check, require IPA version 4.8.0+.
block:
- name: Setup test environment
include_tasks: env_setup.yml
ansible.builtin.include_tasks: env_setup.yml
- name: Ensure service is present
ipaservice:
@@ -575,5 +575,5 @@
# cleanup
- name: Cleanup test environment
include_tasks: env_cleanup.yml
ansible.builtin.include_tasks: env_cleanup.yml
when: ipa_version is version('4.7.0', '>=')

View File

@@ -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 service using client context, in client host.
import_playbook: test_service.yml
ansible.builtin.import_playbook: test_service.yml
when: groups['ipaclients']
vars:
ipa_test_host: ipaclients
- name: Test service using client context, in server host.
import_playbook: test_service.yml
ansible.builtin.import_playbook: test_service.yml
when: groups['ipaclients'] is not defined or not groups['ipaclients']
vars:
ipa_context: client

View File

@@ -14,10 +14,10 @@
tasks:
- name: Get Kerberos ticket for `admin`.
shell: echo SomeADMINpassword | kinit -c ${KRB5CCNAME} admin
ansible.builtin.shell: echo SomeADMINpassword | kinit -c ${KRB5CCNAME} admin
- 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"
@@ -43,10 +43,10 @@
failed_when: not result.changed or result.failed
- name: Obtain keytab
shell: ipa-getkeytab -s "{{ ansible_facts['fqdn'] }}" -p "mysvc1/{{ ansible_facts['fqdn'] }}" -k mysvc1.keytab
ansible.builtin.shell: ipa-getkeytab -s "{{ ansible_facts['fqdn'] }}" -p "mysvc1/{{ ansible_facts['fqdn'] }}" -k mysvc1.keytab
- name: Verify keytab
shell: ipa service-find "mysvc1/{{ ansible_facts['fqdn'] }}"
ansible.builtin.shell: ipa service-find "mysvc1/{{ ansible_facts['fqdn'] }}"
register: result
failed_when: result.failed or result.stdout | regex_search(" Keytab. true")
@@ -59,15 +59,15 @@
failed_when: not result.changed or result.failed
- name: Verify keytab
shell: ipa service-find "mysvc1/{{ ansible_facts['fqdn'] }}"
ansible.builtin.shell: ipa service-find "mysvc1/{{ ansible_facts['fqdn'] }}"
register: result
failed_when: result.failed or result.stdout | regex_search(" Keytab. true")
- name: Obtain keytab
shell: ipa-getkeytab -s "{{ ansible_facts['fqdn'] }}" -p "mysvc1/{{ ansible_facts['fqdn'] }}" -k mysvc1.keytab
ansible.builtin.shell: ipa-getkeytab -s "{{ ansible_facts['fqdn'] }}" -p "mysvc1/{{ ansible_facts['fqdn'] }}" -k mysvc1.keytab
- name: Verify keytab
shell: ipa service-find "mysvc1/{{ ansible_facts['fqdn'] }}"
ansible.builtin.shell: ipa service-find "mysvc1/{{ ansible_facts['fqdn'] }}"
register: result
failed_when: result.failed or result.stdout | regex_search(" Keytab. true")
@@ -80,7 +80,7 @@
failed_when: not result.changed or result.failed
- name: Verify keytab
shell: ipa service-find "mysvc1/{{ ansible_facts['fqdn'] }}"
ansible.builtin.shell: ipa service-find "mysvc1/{{ ansible_facts['fqdn'] }}"
register: result
failed_when: result.failed or result.stdout | regex_search(" Keytab. true")
@@ -98,10 +98,10 @@
name: "mysvc1/{{ ansible_facts['fqdn'] }}"
- name: Destroy Kerberos tickets.
shell: kdestroy -A -q -c ${KRB5CCNAME}
ansible.builtin.shell: kdestroy -A -q -c ${KRB5CCNAME}
- 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]
become: no

View File

@@ -6,7 +6,7 @@
tasks:
# setup
- name: Setup test envirnoment.
include_tasks: env_setup.yml
ansible.builtin.include_tasks: env_setup.yml
# Add service to test keytab create/retrieve attributes.
- name: Ensure test service is present
@@ -394,4 +394,4 @@
# cleanup
- name: Clean-up envirnoment.
include_tasks: env_cleanup.yml
ansible.builtin.include_tasks: env_cleanup.yml

View File

@@ -8,7 +8,7 @@
# setup
- name: Setup test environment
include_tasks: env_setup.yml
ansible.builtin.include_tasks: env_setup.yml
# tests
- name: Ensure service is present
@@ -461,4 +461,4 @@
# cleanup
- name: Cleanup test environment
include_tasks: env_cleanup.yml
ansible.builtin.include_tasks: env_cleanup.yml