mirror of
https://github.com/freeipa/ansible-freeipa.git
synced 2026-05-13 21:12:02 +00:00
ipahost: Add support for several IP addresses and also to change them
ipahost was so far ignoring IP addresses when the host already existed.
This happened because host_mod is not providing functionality to do this.
Now ipaddress is a list and it is possible to ensure a host with several
IP addresses (these can be IPv4 and IPv6). Also it is possible to ensure
presence and absence of IP addresses for an exising host using action
member.
There are no IP address conclict checks as this would lead into issues with
updating an existing host that already is using a duplicate IP address for
example for round-robin (RR). Also this might lead into issues with ensuring
a new host with several IP addresses in this case. Also to ensure a list of
hosts with changing the IP address of one host to another in the list would
result in issues here.
New example playbooks have been added:
playbooks/host/host-present-with-several-ip-addresses.yml
playbooks/host/host-member-ipaddresses-absent.yml
playbooks/host/host-member-ipaddresses-present.yml
A new test has been added for verification:
tests/host/test_host_ipaddresses.yml
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1783976
https://bugzilla.redhat.com/show_bug.cgi?id=1783979
This commit is contained in:
312
tests/host/test_host_ipaddresses.yml
Normal file
312
tests/host/test_host_ipaddresses.yml
Normal file
@@ -0,0 +1,312 @@
|
||||
---
|
||||
- name: Test host IP addresses
|
||||
hosts: ipaserver
|
||||
become: true
|
||||
|
||||
tasks:
|
||||
- name: Get Domain from server name
|
||||
set_fact:
|
||||
ipaserver_domain: "{{ groups.ipaserver[0].split('.')[1:] | join ('.') }}"
|
||||
when: ipaserver_domain is not defined
|
||||
|
||||
- name: Set host1_fqdn .. host6_fqdn
|
||||
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:
|
||||
ipv4_prefix: "{{ ansible_default_ipv4.address.split('.')[:-1] |
|
||||
join('.') }}"
|
||||
|
||||
- name: Host absent
|
||||
ipahost:
|
||||
ipaadmin_password: MyPassword123
|
||||
name:
|
||||
- "{{ host1_fqdn }}"
|
||||
- "{{ host2_fqdn }}"
|
||||
- "{{ host3_fqdn }}"
|
||||
update_dns: yes
|
||||
state: absent
|
||||
|
||||
- name: Host "{{ host1_fqdn }}" present
|
||||
ipahost:
|
||||
ipaadmin_password: MyPassword123
|
||||
name: "{{ host1_fqdn }}"
|
||||
ip_address:
|
||||
- "{{ ipv4_prefix + '.201' }}"
|
||||
- fe80::20c:29ff:fe02:a1b2
|
||||
update_dns: yes
|
||||
reverse: no
|
||||
register: result
|
||||
failed_when: not result.changed
|
||||
|
||||
- name: Host "{{ host1_fqdn }}" present again
|
||||
ipahost:
|
||||
ipaadmin_password: MyPassword123
|
||||
name: "{{ host1_fqdn }}"
|
||||
ip_address:
|
||||
- "{{ ipv4_prefix + '.201' }}"
|
||||
- fe80::20c:29ff:fe02:a1b2
|
||||
update_dns: yes
|
||||
reverse: no
|
||||
register: result
|
||||
failed_when: result.changed
|
||||
|
||||
- name: Host "{{ host1_fqdn }}" present again with new IP address
|
||||
ipahost:
|
||||
ipaadmin_password: MyPassword123
|
||||
name: "{{ host1_fqdn }}"
|
||||
ip_address:
|
||||
- "{{ ipv4_prefix + '.211' }}"
|
||||
- fe80::20c:29ff:fe02:a1b3
|
||||
- "{{ ipv4_prefix + '.221' }}"
|
||||
- fe80::20c:29ff:fe02:a1b4
|
||||
update_dns: yes
|
||||
reverse: no
|
||||
register: result
|
||||
failed_when: not result.changed
|
||||
|
||||
- name: Host "{{ host1_fqdn }}" present again with new IP address again
|
||||
ipahost:
|
||||
ipaadmin_password: MyPassword123
|
||||
name: "{{ host1_fqdn }}"
|
||||
ip_address:
|
||||
- "{{ ipv4_prefix + '.211' }}"
|
||||
- fe80::20c:29ff:fe02:a1b3
|
||||
- "{{ ipv4_prefix + '.221' }}"
|
||||
- fe80::20c:29ff:fe02:a1b4
|
||||
update_dns: yes
|
||||
reverse: no
|
||||
register: result
|
||||
failed_when: result.changed
|
||||
|
||||
- name: Host "{{ host1_fqdn }}" member IPv4 address present
|
||||
ipahost:
|
||||
ipaadmin_password: MyPassword123
|
||||
name: "{{ host1_fqdn }}"
|
||||
ip_address: "{{ ipv4_prefix + '.201' }}"
|
||||
action: member
|
||||
register: result
|
||||
failed_when: not result.changed
|
||||
|
||||
- name: Host "{{ host1_fqdn }}" member IPv4 address present again
|
||||
ipahost:
|
||||
ipaadmin_password: MyPassword123
|
||||
name: "{{ host1_fqdn }}"
|
||||
ip_address: "{{ ipv4_prefix + '.201' }}"
|
||||
action: member
|
||||
register: result
|
||||
failed_when: result.changed
|
||||
|
||||
- name: Host "{{ host1_fqdn }}" member IPv4 address absent
|
||||
ipahost:
|
||||
ipaadmin_password: MyPassword123
|
||||
name: "{{ host1_fqdn }}"
|
||||
ip_address: "{{ ipv4_prefix + '.201' }}"
|
||||
action: member
|
||||
state: absent
|
||||
register: result
|
||||
failed_when: not result.changed
|
||||
|
||||
- name: Host "{{ host1_fqdn }}" member IPv4 address absent again
|
||||
ipahost:
|
||||
ipaadmin_password: MyPassword123
|
||||
name: "{{ host1_fqdn }}"
|
||||
ip_address: "{{ ipv4_prefix + '.201' }}"
|
||||
action: member
|
||||
state: absent
|
||||
register: result
|
||||
failed_when: result.changed
|
||||
|
||||
- name: Host "{{ host1_fqdn }}" member IPv6 address present
|
||||
ipahost:
|
||||
ipaadmin_password: MyPassword123
|
||||
name: "{{ host1_fqdn }}"
|
||||
ip_address: fe80::20c:29ff:fe02:a1b2
|
||||
action: member
|
||||
register: result
|
||||
failed_when: not result.changed
|
||||
|
||||
- name: Host "{{ host1_fqdn }}" member IPv6 address present again
|
||||
ipahost:
|
||||
ipaadmin_password: MyPassword123
|
||||
name: "{{ host1_fqdn }}"
|
||||
ip_address: fe80::20c:29ff:fe02:a1b2
|
||||
action: member
|
||||
register: result
|
||||
failed_when: result.changed
|
||||
|
||||
- name: Host "{{ host1_fqdn }}" member IPv6 address absent
|
||||
ipahost:
|
||||
ipaadmin_password: MyPassword123
|
||||
name: "{{ host1_fqdn }}"
|
||||
ip_address: fe80::20c:29ff:fe02:a1b2
|
||||
action: member
|
||||
state: absent
|
||||
register: result
|
||||
failed_when: not result.changed
|
||||
|
||||
- name: Host "{{ host1_fqdn }}" member IPv6 address absent again
|
||||
ipahost:
|
||||
ipaadmin_password: MyPassword123
|
||||
name: "{{ host1_fqdn }}"
|
||||
ip_address: fe80::20c:29ff:fe02:a1b2
|
||||
action: member
|
||||
state: absent
|
||||
register: result
|
||||
|
||||
- name: Host "{{ host1_fqdn }}" member all ip-addresses absent
|
||||
ipahost:
|
||||
ipaadmin_password: MyPassword123
|
||||
name: "{{ host1_fqdn }}"
|
||||
ip_address:
|
||||
- "{{ ipv4_prefix + '.211' }}"
|
||||
- fe80::20c:29ff:fe02:a1b3
|
||||
- "{{ ipv4_prefix + '.221' }}"
|
||||
- fe80::20c:29ff:fe02:a1b4
|
||||
action: member
|
||||
state: absent
|
||||
register: result
|
||||
failed_when: not result.changed
|
||||
|
||||
- name: Host "{{ host1_fqdn }}" all member ip-addresses absent again
|
||||
ipahost:
|
||||
ipaadmin_password: MyPassword123
|
||||
name: "{{ host1_fqdn }}"
|
||||
ip_address:
|
||||
- "{{ ipv4_prefix + '.211' }}"
|
||||
- fe80::20c:29ff:fe02:a1b3
|
||||
- "{{ ipv4_prefix + '.221' }}"
|
||||
- fe80::20c:29ff:fe02:a1b4
|
||||
action: member
|
||||
state: absent
|
||||
register: result
|
||||
failed_when: result.changed
|
||||
|
||||
- name: Hosts "{{ host1_fqdn }}" and "{{ host2_fqdn }}" present with same IP addresses
|
||||
ipahost:
|
||||
ipaadmin_password: MyPassword123
|
||||
hosts:
|
||||
- name: "{{ host1_fqdn }}"
|
||||
ip_address:
|
||||
- "{{ ipv4_prefix + '.211' }}"
|
||||
- fe80::20c:29ff:fe02:a1b3
|
||||
- "{{ ipv4_prefix + '.221' }}"
|
||||
- fe80::20c:29ff:fe02:a1b4
|
||||
- name: "{{ host2_fqdn }}"
|
||||
ip_address:
|
||||
- "{{ ipv4_prefix + '.211' }}"
|
||||
- fe80::20c:29ff:fe02:a1b3
|
||||
- "{{ ipv4_prefix + '.221' }}"
|
||||
- fe80::20c:29ff:fe02:a1b4
|
||||
register: result
|
||||
failed_when: not result.changed
|
||||
|
||||
- name: Hosts "{{ host1_fqdn }}" and "{{ host2_fqdn }}" present with same IP addresses again
|
||||
ipahost:
|
||||
ipaadmin_password: MyPassword123
|
||||
hosts:
|
||||
- name: "{{ host1_fqdn }}"
|
||||
ip_address:
|
||||
- "{{ ipv4_prefix + '.211' }}"
|
||||
- fe80::20c:29ff:fe02:a1b3
|
||||
- "{{ ipv4_prefix + '.221' }}"
|
||||
- fe80::20c:29ff:fe02:a1b4
|
||||
- name: "{{ host2_fqdn }}"
|
||||
ip_address:
|
||||
- "{{ ipv4_prefix + '.211' }}"
|
||||
- fe80::20c:29ff:fe02:a1b3
|
||||
- "{{ ipv4_prefix + '.221' }}"
|
||||
- fe80::20c:29ff:fe02:a1b4
|
||||
register: result
|
||||
failed_when: result.changed
|
||||
|
||||
- name: Hosts "{{ host3_fqdn }}" present with same IP addresses
|
||||
ipahost:
|
||||
ipaadmin_password: MyPassword123
|
||||
hosts:
|
||||
- name: "{{ host3_fqdn }}"
|
||||
ip_address:
|
||||
- "{{ ipv4_prefix + '.211' }}"
|
||||
- fe80::20c:29ff:fe02:a1b3
|
||||
- "{{ ipv4_prefix + '.221' }}"
|
||||
- fe80::20c:29ff:fe02:a1b4
|
||||
register: result
|
||||
failed_when: not result.changed
|
||||
|
||||
- name: Hosts "{{ host3_fqdn }}" present with same IP addresses again
|
||||
ipahost:
|
||||
ipaadmin_password: MyPassword123
|
||||
hosts:
|
||||
- name: "{{ host3_fqdn }}"
|
||||
ip_address:
|
||||
- "{{ ipv4_prefix + '.211' }}"
|
||||
- fe80::20c:29ff:fe02:a1b3
|
||||
- "{{ ipv4_prefix + '.221' }}"
|
||||
- fe80::20c:29ff:fe02:a1b4
|
||||
register: result
|
||||
failed_when: result.changed
|
||||
|
||||
- name: Host "{{ host3_fqdn }}" present with differnt IP addresses
|
||||
ipahost:
|
||||
ipaadmin_password: MyPassword123
|
||||
hosts:
|
||||
- name: "{{ host3_fqdn }}"
|
||||
ip_address:
|
||||
- "{{ ipv4_prefix + '.111' }}"
|
||||
- fe80::20c:29ff:fe02:a1b1
|
||||
- "{{ ipv4_prefix + '.121' }}"
|
||||
- fe80::20c:29ff:fe02:a1b2
|
||||
register: result
|
||||
failed_when: not result.changed
|
||||
|
||||
- name: Host "{{ host3_fqdn }}" present with different IP addresses again
|
||||
ipahost:
|
||||
ipaadmin_password: MyPassword123
|
||||
hosts:
|
||||
- name: "{{ host3_fqdn }}"
|
||||
ip_address:
|
||||
- "{{ ipv4_prefix + '.111' }}"
|
||||
- fe80::20c:29ff:fe02:a1b1
|
||||
- "{{ ipv4_prefix + '.121' }}"
|
||||
- fe80::20c:29ff:fe02:a1b2
|
||||
register: result
|
||||
failed_when: result.changed
|
||||
|
||||
- name: Host "{{ host3_fqdn }}" present with old IP addresses
|
||||
ipahost:
|
||||
ipaadmin_password: MyPassword123
|
||||
hosts:
|
||||
- name: "{{ host3_fqdn }}"
|
||||
ip_address:
|
||||
- "{{ ipv4_prefix + '.211' }}"
|
||||
- fe80::20c:29ff:fe02:a1b3
|
||||
- "{{ ipv4_prefix + '.221' }}"
|
||||
- fe80::20c:29ff:fe02:a1b4
|
||||
register: result
|
||||
failed_when: not result.changed
|
||||
|
||||
- name: Host "{{ host3_fqdn }}" present with old IP addresses again
|
||||
ipahost:
|
||||
ipaadmin_password: MyPassword123
|
||||
hosts:
|
||||
- name: "{{ host3_fqdn }}"
|
||||
ip_address:
|
||||
- "{{ ipv4_prefix + '.211' }}"
|
||||
- fe80::20c:29ff:fe02:a1b3
|
||||
- "{{ ipv4_prefix + '.221' }}"
|
||||
- fe80::20c:29ff:fe02:a1b4
|
||||
register: result
|
||||
failed_when: result.changed
|
||||
|
||||
- name: Host absent
|
||||
ipahost:
|
||||
ipaadmin_password: MyPassword123
|
||||
name:
|
||||
- "{{ host1_fqdn }}"
|
||||
- "{{ host2_fqdn }}"
|
||||
- "{{ host3_fqdn }}"
|
||||
update_dns: yes
|
||||
state: absent
|
||||
Reference in New Issue
Block a user