migrate ns.xai-corp.net role to ansible-5
This commit is contained in:
10
ansible-5/roles/ns.xai-corp.net/tasks/dynamic_ip.yml
Normal file
10
ansible-5/roles/ns.xai-corp.net/tasks/dynamic_ip.yml
Normal file
@@ -0,0 +1,10 @@
|
||||
---
|
||||
# create cronjob to set dynamic ip
|
||||
|
||||
- name: create zone edit cronjob
|
||||
cron:
|
||||
name: zoneedit
|
||||
minute: "*/30"
|
||||
user: root
|
||||
job: 'IP=`curl -s http://api.ipify.org` && wget -O - --http-user=rmorgan15 --http-passwd=D422B334D3768ACD "https://dynamic.zoneedit.com/auth/dynamic.html?host=test.xai-corp.net&dnsto=$IP" &>/dev/null'
|
||||
cron_file: zoneedit
|
||||
48
ansible-5/roles/ns.xai-corp.net/tasks/main.yml
Normal file
48
ansible-5/roles/ns.xai-corp.net/tasks/main.yml
Normal file
@@ -0,0 +1,48 @@
|
||||
---
|
||||
# tasks/main.yml
|
||||
# define tasks here
|
||||
|
||||
- name: install bind package
|
||||
apt:
|
||||
name: "{{ item }}"
|
||||
update_cache: yes
|
||||
cache_valid_time: 86400
|
||||
state: latest
|
||||
with_items:
|
||||
- bind9
|
||||
|
||||
- name: set correct permissions for logging
|
||||
file:
|
||||
state=directory
|
||||
path=/var/log/named/
|
||||
owner={{ bind.user }}
|
||||
group={{ bind.group }}
|
||||
mode=0777
|
||||
notify:
|
||||
- restart bind
|
||||
|
||||
- name: copy zone files to /etc/bind/
|
||||
template:
|
||||
src: "{{ item }}.j2"
|
||||
dest: /etc/bind/db.{{ item }}
|
||||
owner: "{{ bind.user }}"
|
||||
group: "{{ bind.group }}"
|
||||
mode: 0644
|
||||
with_items: "{{ bind.zonefiles }}"
|
||||
notify:
|
||||
- restart bind
|
||||
|
||||
- name: test zone files
|
||||
command: named-checkzone xai-corp.net /etc/bind/db.xai-corp.net.internal
|
||||
changed_when: false
|
||||
|
||||
- name: copy named.confs to /etc/bind/
|
||||
template: src={{ item }}.j2 dest=/etc/bind/{{ item }} owner={{ bind.user }} group={{ bind.group }} mode=0640
|
||||
with_items:
|
||||
- named.conf.local
|
||||
- named.conf.options
|
||||
- named.conf.default-zones
|
||||
notify:
|
||||
- restart bind
|
||||
|
||||
- include_tasks: dynamic_ip.yml
|
||||
Reference in New Issue
Block a user