Made role OS-specific, added README

This commit is contained in:
Philip (a-0) 2022-07-13 20:14:18 +02:00
parent f04a39cfc6
commit b59417c678
5 changed files with 28 additions and 11 deletions

11
README.md Normal file
View file

@ -0,0 +1,11 @@
ansible role to deploy and configure pihole, including local DNS entries
# Required variables
... e.g. in `group_vars`
- `local_dns_entries` A list of local DNS entries to be set up. Only IPv4 is supported currently. Example:
```
local_dns_entries:
- domain: printer.local
ip4: 192.168.1.50
```
- `pihole_admin_password` The password to be used on the WebUI login. Should be defined in an encrypted ansible vault

View file

@ -1,2 +1,5 @@
--- ---
pihole_os_supported: False pihole_os_supported: False
pihole_primary_dns_server: "208.67.222.220"
pihole_fallback_dns_server: "208.67.222.222"

View file

@ -23,21 +23,21 @@
- name: Check whether pi-hole is installed - name: Check whether pi-hole is installed
stat: stat:
path: /etc/pihole path: "{{ pihole_config_dir }}"
register: pihole_dir register: pihole_dir
- name: Clone the pi-hole repo - name: Clone the pi-hole repo
ansible.builtin.git: ansible.builtin.git:
repo: https://github.com/pi-hole/pi-hole.git repo: https://github.com/pi-hole/pi-hole.git
depth: 1 depth: 1
dest: "/var/pi-hole" dest: "{{ pihole_download_dir }}"
version: master version: master
when: not pihole_dir.stat.exists when: not pihole_dir.stat.exists
- name: Set /etc/pihole/setupVars.conf - name: Set setupVars.conf
template: template:
src: setupVars.conf.j2 src: setupVars.conf.j2
dest: /etc/pihole/setupVars.conf dest: "{{ pihole_config_dir }}setupVars.conf"
owner: root owner: root
mode: 0400 mode: 0400
when: not pihole_dir.stat.exists when: not pihole_dir.stat.exists
@ -45,7 +45,7 @@
# pihole unattented install only works if /etc/pihole/setupVars.conf already exists # pihole unattented install only works if /etc/pihole/setupVars.conf already exists
# debug tip: keep track of the install progress by tailing the log-file # debug tip: keep track of the install progress by tailing the log-file
- name: Run pi-hole install script - name: Run pi-hole install script
ansible.builtin.shell: "'/var/pi-hole/automated install/basic-install.sh' --unattended >> {{ ansible_env.HOME }}/pihole_install.log" ansible.builtin.shell: "'{{ pihole_download_dir }}automated install/basic-install.sh' --unattended >> {{ ansible_env.HOME }}/pihole_install.log"
args: args:
warn: false warn: false
when: not pihole_dir.stat.exists when: not pihole_dir.stat.exists
@ -56,7 +56,7 @@
- name: Set local DNS entries - name: Set local DNS entries
template: template:
src: custom.list.j2 src: custom.list.j2
dest: /etc/pihole/custom.list dest: "{{ pihole_config_dir }}custom.list"
owner: root owner: root
mode: 0664 mode: 0664

View file

@ -8,10 +8,10 @@ LIGHTTPD_ENABLED=true
CACHE_SIZE=10000 CACHE_SIZE=10000
BLOCKING_ENABLED=true BLOCKING_ENABLED=true
{# doesn't matter, password will be set using pihole cli later #} {# doesn't matter, password will be set using pihole cli later #}
WEBPASSWORD=642da416d1acba139eb3514b7ef3318104937f4eeceb8b33663d46c23f56dbfa WEBPASSWORD=642da416d1acba139eb35a948e43318104937f4eeceb8b33663d46c23f56dbfa
DNSMASQ_LISTENING=single DNSMASQ_LISTENING=single
PIHOLE_DNS_1=192.168.2.105#5335 PIHOLE_DNS_1={{ pihole_primary_dns_server }}
PIHOLE_DNS_2=208.67.222.220 PIHOLE_DNS_2={{ pihole_fallback_dns_server }}
DNS_FQDN_REQUIRED=true DNS_FQDN_REQUIRED=true
DNS_BOGUS_PRIV=true DNS_BOGUS_PRIV=true
DNSSEC=false DNSSEC=false

View file

@ -1,2 +1,5 @@
--- ---
pihole_os_supported: True pihole_os_supported: True
pihole_config_dir: /etc/pihole/
pihole_download_dir: /var/pi-hole/