mirror of
https://github.com/freeipa/ansible-freeipa.git
synced 2026-06-10 18:55:53 +00:00
If one tries to set a list of forwarders which include an already existing forwarder, the existing forwarder is removed, and the list of configured forwarders contain only the new ones. This patch fixes this behavior by setting a union of the currently available forwarders and the list of forwarders provided in the playbook. Tests were added to ensure this behavior.
247 lines
7.5 KiB
YAML
247 lines
7.5 KiB
YAML
---
|
|
- name: Test dnsconfig
|
|
hosts: "{{ ipa_test_host | default('ipaserver') }}"
|
|
become: true
|
|
gather_facts: true
|
|
|
|
tasks:
|
|
# Setup.
|
|
- name: Ensure forwarders are absent.
|
|
ipadnsconfig:
|
|
ipaadmin_password: SomeADMINpassword
|
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
|
forwarders:
|
|
- ip_address: 8.8.8.8
|
|
- ip_address: 8.8.4.4
|
|
- ip_address: 2001:4860:4860::8888
|
|
- ip_address: 2001:4860:4860::8888
|
|
port: 53
|
|
state: absent
|
|
|
|
# Tests.
|
|
- name: Set config to invalid IPv4.
|
|
ipadnsconfig:
|
|
ipaadmin_password: SomeADMINpassword
|
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
|
forwarders:
|
|
- ip_address: 1.2.3.500
|
|
register: result
|
|
failed_when: not result.failed or "Invalid IP for DNS forwarder" not in result.msg
|
|
|
|
- name: Set config to invalid IP.
|
|
ipadnsconfig:
|
|
ipaadmin_password: SomeADMINpassword
|
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
|
forwarders:
|
|
- ip_address: 1.in.va.lid
|
|
register: result
|
|
failed_when: not result.failed or "Invalid IP for DNS forwarder" not in result.msg
|
|
|
|
- name: Set config to invalid IPv6.
|
|
ipadnsconfig:
|
|
ipaadmin_password: SomeADMINpassword
|
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
|
forwarders:
|
|
- ip_address: fd00::invalid
|
|
register: result
|
|
failed_when: not result.failed or "Invalid IP for DNS forwarder" not in result.msg
|
|
|
|
- name: Set dnsconfig.
|
|
ipadnsconfig:
|
|
ipaadmin_password: SomeADMINpassword
|
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
|
forwarders:
|
|
- ip_address: 8.8.8.8
|
|
- ip_address: 8.8.4.4
|
|
- ip_address: 2001:4860:4860::8888
|
|
port: 53
|
|
forward_policy: only
|
|
allow_sync_ptr: yes
|
|
register: result
|
|
failed_when: not result.changed or result.failed
|
|
|
|
- name: Set dnsconfig, with the same values.
|
|
ipadnsconfig:
|
|
ipaadmin_password: SomeADMINpassword
|
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
|
forwarders:
|
|
- ip_address: 8.8.8.8
|
|
- ip_address: 8.8.4.4
|
|
- ip_address: 2001:4860:4860::8888
|
|
port: 53
|
|
forward_policy: only
|
|
allow_sync_ptr: yes
|
|
register: result
|
|
failed_when: result.changed or result.failed
|
|
|
|
- name: Ensure forwarder is absent.
|
|
ipadnsconfig:
|
|
ipaadmin_password: SomeADMINpassword
|
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
|
forwarders:
|
|
- ip_address: 8.8.8.8
|
|
state: absent
|
|
register: result
|
|
failed_when: not result.changed or result.failed
|
|
|
|
- name: Ensure forwarder is absent, again.
|
|
ipadnsconfig:
|
|
ipaadmin_password: SomeADMINpassword
|
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
|
forwarders:
|
|
- ip_address: 8.8.8.8
|
|
state: absent
|
|
register: result
|
|
failed_when: result.changed or result.failed
|
|
|
|
- name: Disable global forwarders.
|
|
ipadnsconfig:
|
|
ipaadmin_password: SomeADMINpassword
|
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
|
forward_policy: none
|
|
register: result
|
|
failed_when: not result.changed or result.failed
|
|
|
|
- name: Disable global forwarders, again.
|
|
ipadnsconfig:
|
|
ipaadmin_password: SomeADMINpassword
|
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
|
forward_policy: none
|
|
register: result
|
|
failed_when: result.changed or result.failed
|
|
|
|
- name: Re-enable global forwarders.
|
|
ipadnsconfig:
|
|
ipaadmin_password: SomeADMINpassword
|
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
|
forward_policy: first
|
|
register: result
|
|
failed_when: not result.changed or result.failed
|
|
|
|
- name: Re-enable global forwarders, again.
|
|
ipadnsconfig:
|
|
ipaadmin_password: SomeADMINpassword
|
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
|
forward_policy: first
|
|
register: result
|
|
failed_when: result.changed or result.failed
|
|
|
|
- name: Disable PTR record synchronization.
|
|
ipadnsconfig:
|
|
ipaadmin_password: SomeADMINpassword
|
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
|
allow_sync_ptr: no
|
|
register: result
|
|
failed_when: not result.changed or result.failed
|
|
|
|
- name: Disable PTR record synchronization, again.
|
|
ipadnsconfig:
|
|
ipaadmin_password: SomeADMINpassword
|
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
|
allow_sync_ptr: no
|
|
register: result
|
|
failed_when: result.changed or result.failed
|
|
|
|
- name: Re-enable PTR record synchronization.
|
|
ipadnsconfig:
|
|
ipaadmin_password: SomeADMINpassword
|
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
|
allow_sync_ptr: yes
|
|
register: result
|
|
failed_when: not result.changed or result.failed
|
|
|
|
- name: Re-enable PTR record synchronization, again.
|
|
ipadnsconfig:
|
|
ipaadmin_password: SomeADMINpassword
|
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
|
allow_sync_ptr: yes
|
|
register: result
|
|
failed_when: result.changed or result.failed
|
|
|
|
- name: Ensure all forwarders are absent.
|
|
ipadnsconfig:
|
|
ipaadmin_password: SomeADMINpassword
|
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
|
forwarders:
|
|
- ip_address: 8.8.8.8
|
|
- ip_address: 8.8.4.4
|
|
- ip_address: 2001:4860:4860::8888
|
|
port: 53
|
|
state: absent
|
|
register: result
|
|
failed_when: not result.changed or result.failed
|
|
|
|
- name: Ensure all forwarders are absent, again.
|
|
ipadnsconfig:
|
|
ipaadmin_password: SomeADMINpassword
|
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
|
forwarders:
|
|
- ip_address: 8.8.8.8
|
|
- ip_address: 8.8.4.4
|
|
- ip_address: 2001:4860:4860::8888
|
|
port: 53
|
|
state: absent
|
|
register: result
|
|
failed_when: result.changed or result.failed
|
|
|
|
- name: Ensure forwarder is present.
|
|
ipadnsconfig:
|
|
ipaadmin_password: SomeADMINpassword
|
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
|
forwarders:
|
|
- ip_address: 8.8.8.8
|
|
register: result
|
|
failed_when: not result.changed or result.failed
|
|
|
|
- name: Ensure forwarders are present.
|
|
ipadnsconfig:
|
|
ipaadmin_password: SomeADMINpassword
|
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
|
forwarders:
|
|
- ip_address: 8.8.4.4
|
|
- ip_address: 8.8.8.8
|
|
register: result
|
|
failed_when: not result.changed or result.failed
|
|
|
|
- name: Ensure forwarders are present, again.
|
|
ipadnsconfig:
|
|
ipaadmin_password: SomeADMINpassword
|
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
|
forwarders:
|
|
- ip_address: 8.8.4.4
|
|
- ip_address: 8.8.8.8
|
|
register: result
|
|
failed_when: result.changed or result.failed
|
|
|
|
- name: Ensure another forwarder is present.
|
|
ipadnsconfig:
|
|
ipaadmin_password: SomeADMINpassword
|
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
|
forwarders:
|
|
- ip_address: 8.8.4.4
|
|
register: result
|
|
failed_when: result.changed or result.failed
|
|
|
|
- name: Ensure forwarders are present.
|
|
ipadnsconfig:
|
|
ipaadmin_password: SomeADMINpassword
|
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
|
forwarders:
|
|
- ip_address: 8.8.4.4
|
|
- ip_address: 8.8.8.8
|
|
register: result
|
|
failed_when: result.changed or result.failed
|
|
|
|
# Cleanup.
|
|
- name: Ensure forwarders are absent.
|
|
ipadnsconfig:
|
|
ipaadmin_password: SomeADMINpassword
|
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
|
forwarders:
|
|
- ip_address: 8.8.8.8
|
|
- ip_address: 8.8.4.4
|
|
- ip_address: 2001:4860:4860::8888
|
|
- ip_address: 2001:4860:4860::8888
|
|
port: 53
|
|
state: absent
|