mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-27 10:40:22 -07:00
Add gandi_livedns module (#328)
* Add gandi_livedns module This module uses REST API to register, update and delete domain name entries in Gandi DNS service (https://www.gandi.net/en/domain). * Apply suggestions from code review * Update plugins/module_utils/gandi_livedns_api.py Co-authored-by: Gregory Thiemonge <greg@thiemonge.org> Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
606eb0df15
commit
81f3ad45c9
10 changed files with 652 additions and 0 deletions
2
tests/integration/targets/gandi_livedns/aliases
Normal file
2
tests/integration/targets/gandi_livedns/aliases
Normal file
|
@ -0,0 +1,2 @@
|
|||
cloud/gandi
|
||||
unsupported
|
34
tests/integration/targets/gandi_livedns/defaults/main.yml
Normal file
34
tests/integration/targets/gandi_livedns/defaults/main.yml
Normal file
|
@ -0,0 +1,34 @@
|
|||
# Copyright: (c) 2020 Gregory Thiemonge <gregory.thiemonge@gmail.com>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
---
|
||||
gandi_livedns_domain_name: "ansible-tests.org"
|
||||
gandi_livedns_record_items:
|
||||
# Single A record
|
||||
- record: test-www
|
||||
type: A
|
||||
values:
|
||||
- 10.10.10.10
|
||||
ttl: 400
|
||||
update_values:
|
||||
- 10.10.10.11
|
||||
update_ttl: 800
|
||||
|
||||
# Multiple A records
|
||||
- record: test-www-multiple
|
||||
type: A
|
||||
ttl: 3600
|
||||
values:
|
||||
- 10.10.11.10
|
||||
- 10.10.11.10
|
||||
update_values:
|
||||
- 10.10.11.11
|
||||
- 10.10.11.13
|
||||
|
||||
# CNAME
|
||||
- record: test-cname
|
||||
type: CNAME
|
||||
ttl: 10800
|
||||
values:
|
||||
- test-www2
|
||||
update_values:
|
||||
- test-www
|
|
@ -0,0 +1,67 @@
|
|||
# Copyright: (c) 2020 Gregory Thiemonge <gregory.thiemonge@gmail.com>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
---
|
||||
- name: test absent dns record
|
||||
community.general.gandi_livedns:
|
||||
api_key: "{{ gandi_api_key }}"
|
||||
record: "{{ item.record }}"
|
||||
domain: "{{ gandi_livedns_domain_name }}"
|
||||
type: "{{ item.type }}"
|
||||
ttl: "{{ item.ttl }}"
|
||||
state: absent
|
||||
register: result
|
||||
- name: verify test absent dns record
|
||||
assert:
|
||||
that:
|
||||
- result is successful
|
||||
|
||||
- name: test create a dns record in check mode
|
||||
community.general.gandi_livedns:
|
||||
api_key: "{{ gandi_api_key }}"
|
||||
record: "{{ item.record }}"
|
||||
domain: "{{ gandi_livedns_domain_name }}"
|
||||
values: "{{ item['values'] }}"
|
||||
ttl: "{{ item.ttl }}"
|
||||
type: "{{ item.type }}"
|
||||
check_mode: yes
|
||||
register: result
|
||||
- name: verify test create a dns record in check mode
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: test create a dns record
|
||||
community.general.gandi_livedns:
|
||||
api_key: "{{ gandi_api_key }}"
|
||||
record: "{{ item.record }}"
|
||||
domain: "{{ gandi_livedns_domain_name }}"
|
||||
values: "{{ item['values'] }}"
|
||||
ttl: "{{ item.ttl }}"
|
||||
type: "{{ item.type }}"
|
||||
register: result
|
||||
- name: verify test create a dns record
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
- result.record['values'] == {{ item['values'] }}
|
||||
- result.record.record == "{{ item.record }}"
|
||||
- result.record.type == "{{ item.type }}"
|
||||
- result.record.ttl == {{ item.ttl }}
|
||||
|
||||
- name: test create a dns record idempotence
|
||||
community.general.gandi_livedns:
|
||||
api_key: "{{ gandi_api_key }}"
|
||||
record: "{{ item.record }}"
|
||||
domain: "{{ gandi_livedns_domain_name }}"
|
||||
values: "{{ item['values'] }}"
|
||||
ttl: "{{ item.ttl }}"
|
||||
type: "{{ item.type }}"
|
||||
register: result
|
||||
- name: verify test create a dns record idempotence
|
||||
assert:
|
||||
that:
|
||||
- result is not changed
|
||||
- result.record['values'] == {{ item['values'] }}
|
||||
- result.record.record == "{{ item.record }}"
|
||||
- result.record.type == "{{ item.type }}"
|
||||
- result.record.ttl == {{ item.ttl }}
|
5
tests/integration/targets/gandi_livedns/tasks/main.yml
Normal file
5
tests/integration/targets/gandi_livedns/tasks/main.yml
Normal file
|
@ -0,0 +1,5 @@
|
|||
# Copyright: (c) 2020 Gregory Thiemonge <gregory.thiemonge@gmail.com>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
---
|
||||
- include_tasks: record.yml
|
||||
with_items: "{{ gandi_livedns_record_items }}"
|
6
tests/integration/targets/gandi_livedns/tasks/record.yml
Normal file
6
tests/integration/targets/gandi_livedns/tasks/record.yml
Normal file
|
@ -0,0 +1,6 @@
|
|||
# Copyright: (c) 2020 Gregory Thiemonge <gregory.thiemonge@gmail.com>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
---
|
||||
- include_tasks: create_record.yml
|
||||
- include_tasks: update_record.yml
|
||||
- include_tasks: remove_record.yml
|
|
@ -0,0 +1,59 @@
|
|||
# Copyright: (c) 2020 Gregory Thiemonge <gregory.thiemonge@gmail.com>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
---
|
||||
- name: test remove a dns record in check mode
|
||||
community.general.gandi_livedns:
|
||||
api_key: "{{ gandi_api_key }}"
|
||||
record: "{{ item.record }}"
|
||||
domain: "{{ gandi_livedns_domain_name }}"
|
||||
values: "{{ item.update_values | default(item['values']) }}"
|
||||
type: "{{ item.type }}"
|
||||
state: absent
|
||||
check_mode: yes
|
||||
register: result
|
||||
- name: verify test remove a dns record in check mode
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: test remove a dns record
|
||||
community.general.gandi_livedns:
|
||||
api_key: "{{ gandi_api_key }}"
|
||||
record: "{{ item.record }}"
|
||||
domain: "{{ gandi_livedns_domain_name }}"
|
||||
values: "{{ item.update_values | default(item['values']) }}"
|
||||
type: "{{ item.type }}"
|
||||
state: absent
|
||||
register: result
|
||||
- name: verify test remove a dns record
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: test remove a dns record idempotence
|
||||
community.general.gandi_livedns:
|
||||
api_key: "{{ gandi_api_key }}"
|
||||
record: "{{ item.record }}"
|
||||
domain: "{{ gandi_livedns_domain_name }}"
|
||||
values: "{{ item.update_values | default(item['values']) }}"
|
||||
type: "{{ item.type }}"
|
||||
state: absent
|
||||
register: result
|
||||
- name: verify test remove a dns record idempotence
|
||||
assert:
|
||||
that:
|
||||
- result is not changed
|
||||
|
||||
- name: test remove second dns record idempotence
|
||||
community.general.gandi_livedns:
|
||||
api_key: "{{ gandi_api_key }}"
|
||||
record: "{{ item.record }}"
|
||||
domain: "{{ gandi_livedns_domain_name }}"
|
||||
values: "{{ item['values'] }}"
|
||||
type: "{{ item.type }}"
|
||||
state: absent
|
||||
register: result
|
||||
- name: verify test remove a dns record idempotence
|
||||
assert:
|
||||
that:
|
||||
- result is not changed
|
|
@ -0,0 +1,57 @@
|
|||
# Copyright: (c) 2020 Gregory Thiemonge <gregory.thiemonge@gmail.com>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
---
|
||||
- name: test update or add another dns record in check mode
|
||||
community.general.gandi_livedns:
|
||||
api_key: "{{ gandi_api_key }}"
|
||||
record: "{{ item.record }}"
|
||||
domain: "{{ gandi_livedns_domain_name }}"
|
||||
values: "{{ item.update_values | default(item['values']) }}"
|
||||
ttl: "{{ item.update_ttl | default(item.ttl) }}"
|
||||
type: "{{ item.type }}"
|
||||
check_mode: yes
|
||||
register: result
|
||||
- name: verify test update in check mode
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
- result.record['values'] == {{ item.update_values | default(item['values']) }}
|
||||
- result.record.record == "{{ item.record }}"
|
||||
- result.record.type == "{{ item.type }}"
|
||||
- result.record.ttl == {{ item.update_ttl | default(item.ttl) }}
|
||||
|
||||
- name: test update or add another dns record
|
||||
community.general.gandi_livedns:
|
||||
api_key: "{{ gandi_api_key }}"
|
||||
record: "{{ item.record }}"
|
||||
domain: "{{ gandi_livedns_domain_name }}"
|
||||
values: "{{ item.update_values | default(item['values']) }}"
|
||||
ttl: "{{ item.update_ttl | default(item.ttl) }}"
|
||||
type: "{{ item.type }}"
|
||||
register: result
|
||||
- name: verify test update a dns record
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
- result.record['values'] == {{ item.update_values | default(item['values']) }}
|
||||
- result.record.record == "{{ item.record }}"
|
||||
- result.record.ttl == {{ item.update_ttl | default(item.ttl) }}
|
||||
- result.record.type == "{{ item.type }}"
|
||||
|
||||
- name: test update or add another dns record idempotence
|
||||
community.general.gandi_livedns:
|
||||
api_key: "{{ gandi_api_key }}"
|
||||
record: "{{ item.record }}"
|
||||
domain: "{{ gandi_livedns_domain_name }}"
|
||||
values: "{{ item.update_values | default(item['values']) }}"
|
||||
ttl: "{{ item.update_ttl | default(item.ttl) }}"
|
||||
type: "{{ item.type }}"
|
||||
register: result
|
||||
- name: verify test update a dns record idempotence
|
||||
assert:
|
||||
that:
|
||||
- result is not changed
|
||||
- result.record['values'] == {{ item.update_values | default(item['values']) }}
|
||||
- result.record.record == "{{ item.record }}"
|
||||
- result.record.ttl == {{ item.update_ttl | default(item.ttl) }}
|
||||
- result.record.type == "{{ item.type }}"
|
Loading…
Add table
Add a link
Reference in a new issue