mirror of
https://github.com/freeipa/ansible-freeipa.git
synced 2026-05-08 06:13:21 +00:00
Merge pull request #203 from t-woerner/ipahost_ipaddresses
ipahost: Add support for several IP addresses and also to change them
This commit is contained in:
@@ -129,7 +129,7 @@
|
||||
- name: Host "{{ host5_fqdn }}" present again
|
||||
ipahost:
|
||||
ipaadmin_password: MyPassword123
|
||||
name: "{{ host1_fqdn }}"
|
||||
name: "{{ host5_fqdn }}"
|
||||
ip_address: "{{ ipv4_prefix + '.205' }}"
|
||||
update_dns: yes
|
||||
reverse: no
|
||||
|
||||
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