63 lines
1.7 KiB
YAML
63 lines
1.7 KiB
YAML
---
|
|
- name: Assert Debian-based distribution
|
|
ansible.builtin.assert:
|
|
that:
|
|
- ansible_os_family == 'Debian'
|
|
fail_msg: "ansible-role-pihole only supports Debian-based distributions"
|
|
|
|
- name: Install Pi-hole prerequisites
|
|
ansible.builtin.apt:
|
|
name:
|
|
- curl
|
|
- git
|
|
- dhcpcd5
|
|
state: present
|
|
update_cache: true
|
|
become: true
|
|
|
|
- name: Create /etc/pihole directory
|
|
ansible.builtin.file:
|
|
path: /etc/pihole
|
|
state: directory
|
|
mode: '0755'
|
|
become: true
|
|
|
|
- name: Write setupVars.conf for unattended installation
|
|
ansible.builtin.copy:
|
|
content: |
|
|
PIHOLE_INTERFACE={{ pihole_interface }}
|
|
IPV4_ADDRESS={{ pihole_ipv4_address }}
|
|
PIHOLE_DNS_1={{ pihole_dns_1 }}
|
|
PIHOLE_DNS_2={{ pihole_dns_2 }}
|
|
QUERY_LOGGING={{ pihole_query_logging }}
|
|
INSTALL_WEB_SERVER={{ pihole_install_web_server }}
|
|
INSTALL_WEB_INTERFACE={{ pihole_install_web_interface }}
|
|
LIGHTTPD_ENABLED={{ pihole_lighttpd_enabled }}
|
|
CACHE_SIZE={{ pihole_cache_size }}
|
|
DNS_FLUSHED_ON_RESTART=true
|
|
DNSSEC=false
|
|
TEMPERATUREUNIT=C
|
|
WEBUIBOXEDLAYOUT=traditional
|
|
API_PRIVACY_MODE=false
|
|
BLOCKING_ENABLED=true
|
|
dest: /etc/pihole/setupVars.conf
|
|
mode: '0644'
|
|
become: true
|
|
|
|
- name: Download Pi-hole installer
|
|
ansible.builtin.get_url:
|
|
url: https://install.pi-hole.net
|
|
dest: /tmp/pihole-installer.sh
|
|
mode: '0755'
|
|
|
|
- name: Run Pi-hole unattended installer
|
|
ansible.builtin.command:
|
|
cmd: /tmp/pihole-installer.sh --unattended
|
|
creates: /usr/local/bin/pihole
|
|
become: true
|
|
|
|
- name: Remove Pi-hole installer script
|
|
ansible.builtin.file:
|
|
path: /tmp/pihole-installer.sh
|
|
state: absent
|