test using a list of records

This commit is contained in:
2023-10-05 15:57:02 +02:00
parent 8270ba251c
commit 1377468c37
3 changed files with 29 additions and 13 deletions

View File

@@ -1,4 +1,4 @@
Role Name
Rôles Name
=========
Add or remove dns records
@@ -16,7 +16,8 @@ ovh_api_application_key
ovh_api_application_secret
ovh_api_consumer_key
record_name
dns_records:
- record_name
record_value
record_type
dns_action: delete or add
@@ -30,8 +31,16 @@ Example Playbook
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
- hosts: localhost
vars:
dns_records:
- record_name: foobar.opendoor.fr
record_value: 1.2.3.4
record_type: "A"
- record_name: plop.opendoor.fr
record_value: foobar.opendoor.fr.
record__type: CNAME
roles:
- { role: tco.dns, record_name: "foobar.opendoor.fr", record_value: "1.2.3.43, record_type: 'A', dns_action: 'add' }
- { role: tco.dns, dns_records: {{ dns_records }}" }
License
-------

View File

@@ -1,5 +1,6 @@
---
# tasks file for tco.dns
- name: manage dns record
vars:
state: "{{ (dns_action == 'delete' ) | ternary( 'absent', 'present' ) }}"
@@ -9,8 +10,8 @@
ovh_api_application_secret: "{{ ovh_api_application_secret }}"
ovh_api_consumer_key: "{{ ovh_api_consumer_key }}"
zone: "{{ dns_zone }}"
record_name: "{{ record_name }}"
record_value: "{{ record_value }}"
record_type: "{{ record_type }}"
record_name: "{{ item.record_name }}"
record_value: "{{ item.record_value }}"
record_type: "{{ item.record_type }}"
state: "{{ state }}"
loop: "{{ dns_records }}"

View File

@@ -1,5 +1,11 @@
---
- hosts: localhost
remote_user: root
vars:
records:
- record_name: test1
record_value: 1.2.3.4
record_type: "A"
- record_name: test2
record_value: foobar.opendoor.fr.
record_type: CNAME
roles:
- tco.dns
- { role: tco.dns, dns_action: "delete", dns_records: "{{ records }}" }