Files
ansible-freeipa/tests/host/test_hosts_managedby_host.yml
Thomas Woerner 473ed03e26 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
2022-12-20 13:50:23 +01:00

152 lines
4.9 KiB
YAML

---
- name: Test hosts managedby_host
hosts: ipaserver
become: true
tasks:
- name: Get Domain from server name
ansible.builtin.set_fact:
ipaserver_domain: "{{ ansible_facts['fqdn'].split('.')[1:] | join ('.') }}"
when: ipaserver_domain is not defined
- name: Set host1_fqdn .. host5_fqdn
ansible.builtin.set_fact:
host1_fqdn: "{{ 'host1.' + ipaserver_domain }}"
host2_fqdn: "{{ 'host2.' + ipaserver_domain }}"
host3_fqdn: "{{ 'host3.' + ipaserver_domain }}"
host4_fqdn: "{{ 'host4.' + ipaserver_domain }}"
host5_fqdn: "{{ 'host5.' + ipaserver_domain }}"
- name: Host absent
ipahost:
ipaadmin_password: SomeADMINpassword
name:
- "{{ host1_fqdn }}"
- "{{ host2_fqdn }}"
- "{{ host3_fqdn }}"
- "{{ host4_fqdn }}"
- "{{ host5_fqdn }}"
update_dns: yes
state: absent
- name: Host "{{ host5_fqdn }}" present
ipahost:
ipaadmin_password: SomeADMINpassword
name: "{{ host5_fqdn }}"
force: yes
register: result
failed_when: not result.changed or result.failed
- name: Hosts "{{ host1_fqdn }}" .. "{{ 'host5.' + ipaserver_domain }}" present and managed by "{{ 'host5.' + ipaserver_domain }}"
ipahost:
ipaadmin_password: SomeADMINpassword
hosts:
- name: "{{ host1_fqdn }}"
managedby_host: "{{ host5_fqdn }}"
force: yes
- name: "{{ host2_fqdn }}"
managedby_host: "{{ host5_fqdn }}"
force: yes
- name: "{{ host3_fqdn }}"
managedby_host: "{{ host5_fqdn }}"
force: yes
- name: "{{ host4_fqdn }}"
managedby_host: "{{ host5_fqdn }}"
force: yes
- name: "{{ host5_fqdn }}"
managedby_host: "{{ host5_fqdn }}"
force: yes
register: result
failed_when: not result.changed or result.failed
- name: Hosts "{{ host1_fqdn }}" .. "{{ 'host5.' + ipaserver_domain }}" present and managed by "{{ 'host5.' + ipaserver_domain }}" again
ipahost:
ipaadmin_password: SomeADMINpassword
hosts:
- name: "{{ host1_fqdn }}"
managedby_host: "{{ host5_fqdn }}"
force: yes
- name: "{{ host2_fqdn }}"
managedby_host: "{{ host5_fqdn }}"
force: yes
- name: "{{ host3_fqdn }}"
managedby_host: "{{ host5_fqdn }}"
force: yes
- name: "{{ host4_fqdn }}"
managedby_host: "{{ host5_fqdn }}"
force: yes
- name: "{{ host5_fqdn }}"
managedby_host: "{{ host5_fqdn }}"
force: yes
register: result
failed_when: result.changed or result.failed
- name: Hosts "{{ host1_fqdn }}" .. "{{ 'host5.' + ipaserver_domain }}" managed by "{{ 'host5.' + ipaserver_domain }}"
ipahost:
ipaadmin_password: SomeADMINpassword
hosts:
- name: "{{ host1_fqdn }}"
managedby_host: "{{ host5_fqdn }}"
- name: "{{ host2_fqdn }}"
managedby_host: "{{ host5_fqdn }}"
- name: "{{ host3_fqdn }}"
managedby_host: "{{ host5_fqdn }}"
- name: "{{ host4_fqdn }}"
managedby_host: "{{ host5_fqdn }}"
- name: "{{ host5_fqdn }}"
managedby_host: "{{ host5_fqdn }}"
action: member
register: result
failed_when: result.changed or result.failed
- name: Hosts "{{ host1_fqdn }}" .. "{{ 'host5.' + ipaserver_domain }}" not managed by "{{ 'host5.' + ipaserver_domain }}"
ipahost:
ipaadmin_password: SomeADMINpassword
hosts:
- name: "{{ host1_fqdn }}"
managedby_host: "{{ host5_fqdn }}"
- name: "{{ host2_fqdn }}"
managedby_host: "{{ host5_fqdn }}"
- name: "{{ host3_fqdn }}"
managedby_host: "{{ host5_fqdn }}"
- name: "{{ host4_fqdn }}"
managedby_host: "{{ host5_fqdn }}"
- name: "{{ host5_fqdn }}"
managedby_host: "{{ host5_fqdn }}"
action: member
state: absent
register: result
failed_when: not result.changed or result.failed
- name: Hosts "{{ host1_fqdn }}" .. "{{ 'host5.' + ipaserver_domain }}" not managed by "{{ 'host5.' + ipaserver_domain }}" again
ipahost:
ipaadmin_password: SomeADMINpassword
hosts:
- name: "{{ host1_fqdn }}"
managedby_host: "{{ host5_fqdn }}"
- name: "{{ host2_fqdn }}"
managedby_host: "{{ host5_fqdn }}"
- name: "{{ host3_fqdn }}"
managedby_host: "{{ host5_fqdn }}"
- name: "{{ host4_fqdn }}"
managedby_host: "{{ host5_fqdn }}"
- name: "{{ host5_fqdn }}"
managedby_host: "{{ host5_fqdn }}"
action: member
state: absent
register: result
failed_when: result.changed or result.failed
- name: Hosts "{{ host1_fqdn }}" .. "{{ 'host5.' + ipaserver_domain }}" absent
ipahost:
ipaadmin_password: SomeADMINpassword
hosts:
- name: "{{ host1_fqdn }}"
- name: "{{ host2_fqdn }}"
- name: "{{ host3_fqdn }}"
- name: "{{ host4_fqdn }}"
- name: "{{ host5_fqdn }}"
state: absent
register: result
failed_when: not result.changed or result.failed