Kapisi/roles/Chappaai/tasks/main.yml

81 lines
1.7 KiB
YAML
Raw Normal View History

2020-10-08 16:33:19 -05:00
---
2021-12-19 21:32:19 -06:00
- name: Clone pi-hole
2020-10-08 16:33:19 -05:00
become: yes
2021-12-19 21:32:19 -06:00
git:
accept_newhostkey: yes
dest: /opt/pi-hole
repo: https://github.com/pi-hole/pi-hole.git
- name: Install pi-hole if needed
become: yes
2022-03-25 06:08:12 -05:00
register: pihole_install
command:
2021-12-19 21:32:19 -06:00
creates: /usr/bin/pihole-FTL
2022-03-25 06:08:12 -05:00
cmd: false # bash basic-install.sh
2021-12-19 21:32:19 -06:00
chdir: '/opt/pi-hole/automated install'
2022-03-25 06:08:12 -05:00
- name: Ensure pihole web admin password
become: yes
command: "pihole -a -p {{ passwords['Chappaai'] }}"
2022-03-25 06:08:12 -05:00
# when: pihole_install.changed
2021-12-19 21:32:19 -06:00
- name: Generate DNS/DHCP from inventory
delegate_to: localhost
run_once: true
command: "python3 ../bin/generate-pihole-dns-dhcp.py {{ inventory_file }}"
- name: Chappaai DNS
2021-12-19 21:32:19 -06:00
become: yes
register: dns_updated
copy:
dest: /etc/pihole/custom.list
src: dns
2021-12-19 21:32:19 -06:00
owner: pihole
group: pihole
mode: 0644
- name: Chappaai DHCP
2021-12-19 21:32:19 -06:00
become: yes
register: dhcp_updated
copy:
src: dhcp
dest: /etc/dnsmasq.d/04-pihole-static-dhcp.conf
owner: root
group: root
mode: 0644
- name: Chappaai Configuration
2022-03-25 06:08:12 -05:00
become: yes
register: conf_updated
copy:
src: pihole-FTL.conf
dest: /etc/pihole/pihole-FTL.conf
owner: root
group: root
mode: 0644
- name: Chappaai DHCP Leases dir
2022-03-25 06:08:12 -05:00
become: yes
file:
path: /var/lib/misc/
state: directory
owner: root
group: root
mode: 0777
- name: Chappaai DHCP Leases
2022-03-25 06:08:12 -05:00
become: yes
file:
path: /var/lib/misc/dnsmasq.leases
state: touch
owner: pihole
group: pihole
mode: 0660
2021-12-19 21:32:19 -06:00
- name: Reload services
become: yes
command: pihole restartdns
2022-03-25 06:08:12 -05:00
when: dns_updated.changed or dhcp_updated.changed or conf_updated.changed