move record state to vars, support removal
This commit is contained in:
parent
0e6228b751
commit
2d4dc4ac48
4 changed files with 14 additions and 13 deletions
2
domains
2
domains
|
@ -1 +1 @@
|
||||||
roles/create-records/vars
|
roles/manage-records/vars
|
|
@ -1,16 +1,15 @@
|
||||||
---
|
---
|
||||||
|
|
||||||
- name: "create records ({{domain}})"
|
- name: "manage records for ({{ domain }})"
|
||||||
cloudflare_dns:
|
cloudflare_dns:
|
||||||
zone: "{{ domain }}"
|
zone: "{{ domain }}"
|
||||||
record: "{{ record.name }}"
|
record: "{{ record.name }}"
|
||||||
value: "{{ record.value }}"
|
value: "{{ record.value }}"
|
||||||
type: "{{ record.type }}"
|
type: "{{ record.type }}"
|
||||||
solo: yes
|
solo: "{{ 'yes' if record.state in ['present'] | default(false) else omit }}"
|
||||||
state: present
|
state: "{{ record.state }}" # don't assume / set a default, require explicit instruction
|
||||||
account_email: "{{ cf_email }}"
|
account_email: "{{ cf_email }}"
|
||||||
account_api_token: "{{ cf_token }}"
|
account_api_token: "{{ cf_token }}"
|
||||||
loop: "{{ records }}"
|
loop: "{{ records }}"
|
||||||
loop_control:
|
loop_control:
|
||||||
loop_var: record
|
loop_var: record
|
||||||
when: (item.state is undefined) or (not item.state == 'absent')
|
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
domain: sampledomain.local
|
|
||||||
records:
|
|
||||||
- name: 'subdomain'
|
|
||||||
value: '127.0.0.1'
|
|
||||||
type: A
|
|
||||||
- name: 'subdomain'
|
|
||||||
value: '::1'
|
|
||||||
type: AAAA
|
|
10
roles/manage-records/vars/sampledomain.local.yml
Normal file
10
roles/manage-records/vars/sampledomain.local.yml
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
domain: sampledomain.local
|
||||||
|
records:
|
||||||
|
- name: 'subdomain' # create a silly localhost subdomain.sampledomain.io A record (IPv4)
|
||||||
|
value: '127.0.0.1'
|
||||||
|
type: A
|
||||||
|
state: present
|
||||||
|
- name: 'subdomain' # remove equally silly subdomain.sampledomain.io AAAA record (IPv6 local)
|
||||||
|
value: '::1'
|
||||||
|
type: AAAA
|
||||||
|
state: absent
|
Loading…
Reference in a new issue