modernize, break out domains into vars files

This commit is contained in:
Josh Lay 2021-12-18 21:30:46 -06:00
parent 5a16d04975
commit 7e17cf6b41
4 changed files with 25 additions and 33 deletions

View file

@ -3,5 +3,14 @@
hosts: localhost hosts: localhost
connection: local connection: local
gather_facts: smart gather_facts: smart
roles: vars:
- create-records domains:
- jlay.io
- jlay.dev
- init3.io
tasks:
- name: "enforce state for {{item}}"
include_role:
name: create-records
vars_from: "{{item}}"
with_items: "{{domains}}"

View file

@ -1,14 +0,0 @@
---
zones:
- name: jlay.dev
state: present
records:
- name: git.ry1
value: "107.181.235.67"
type: A
- name: ry1
value: "107.181.235.66"
type: A
- name: ry2
value: "107.181.235.74"
type: A

View file

@ -4,5 +4,17 @@
include_vars: include_vars:
file: "~/.cloudflare.yml" file: "~/.cloudflare.yml"
- include_tasks: zone.yml - name: "create records ({{domain}})"
loop: "{{ zones }}" cloudflare_dns:
zone: "{{ domain }}"
record: "{{ record.name }}"
value: "{{ record.value }}"
type: "{{ record.type }}"
solo: yes
state: present
account_email: "{{ cf_email }}"
account_api_token: "{{ cf_token }}"
loop: "{{ records }}"
loop_control:
loop_var: record
when: (item.state is undefined) or (not item.state == 'absent')

View file

@ -1,15 +0,0 @@
---
- name: create records
cloudflare_dns:
zone: "{{ item.name }}"
record: "{{ record.name }}"
value: "{{ record.value }}"
type: "{{ record.type }}"
solo: yes
account_email: "{{ cf_email }}"
account_api_token: "{{ cf_token }}"
loop: "{{ item.records }}"
loop_control:
loop_var: record
when: (not item.state == 'absent')