-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added: * pihole_idempotent. This will force role to be idempotent each run. Classic behavior is 'false' (not idempotent); but may now be optionally toggled on. Changed: * Added 'Default' group to blocklist defaults to conform to pihole defaults. * Added 'remove_default_group' to 'pihole_clients' (backwards compatible). Hosts toggling this flag will be removed from the 'Default' group on role application. * Adding clients moved to separate 'add_clients' file enabling management of client and removal of 'Default' group in one loop. * Databases may now be removed on role application to enable idempotent runs.
- Loading branch information
Showing
9 changed files
with
95 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--- | ||
############################################################################### | ||
# Pi-Hole Add Clients | ||
############################################################################### | ||
# Clients are automatically added to the 'Default' (id=0) group in Pi-Hole upon | ||
# creation, which apply the default blocklists. Add clients and optionally | ||
# remove them from the 'Default' if enabled. | ||
# | ||
# Args: | ||
# client: dict (pihole_clients) | ||
# - id: int (unique id starting at 1) | ||
# ip: str (IPv4,IPv6,CIDR) | ||
# comment: str (user comment) | ||
# remove_default_group: bool (remove from automatic 'Default' group) | ||
# | ||
# Reference: | ||
# * https://docs.pi-hole.net/database/ | ||
|
||
- name: 'db | add client {{ client.id }}' | ||
ansible.builtin.command: '{{ pihole_default_sqlite3 }} "{{ pihole_default_client_insert }} ({{ client.id }}, \"{{ client.ip }}\", \"{{ client.comment }}\")"' | ||
become: true | ||
|
||
- name: 'db | remove client {{ client.id }} from default group' | ||
ansible.builtin.command: '{{ pihole_default_sqlite3 }} "{{ pihole_default_client_groups_delete_default }} {{ client.id }}"' | ||
become: true | ||
when: | | ||
'remove_default_group' in client and | ||
client.remove_default_group |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
############################################################################### | ||
# Pi-Hole Clear Databases | ||
############################################################################### | ||
# Removes existing databases for Pi-Hole to rebuild on restart. This enables | ||
# idempotent role application for Pi-Hole. | ||
# | ||
# Given the DB triggers and simplistic nature of handling clients; major | ||
# changes to clients and groups (including additions, removals) **WILL** lead | ||
# to a skew in the actual database versus what the role explicitly codifies. | ||
# | ||
# By removing the databases before applying changes, this enables consistent | ||
# application at the expense of recreating the DB's and downloading/rebuilding | ||
# blocklists each run. | ||
|
||
- name: 'clear databases | remove databases' | ||
ansible.builtin.file: | ||
path: '/etc/pihole/{{ item }}' | ||
state: 'absent' | ||
loop: | ||
- 'gravity.db' | ||
- 'pihole-FTL.db' | ||
|
||
- name: 'clear databases | regenerate databases' | ||
ansible.builtin.command: '/etc/.pihole/automated\ install/basic-install.sh --reconfigure --unattended' | ||
changed_when: false |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
--- | ||
- ansible.builtin.import_tasks: install.yml | ||
- ansible.builtin.import_tasks: db.yml | ||
- ansible.builtin.import_tasks: db/db.yml | ||
- ansible.builtin.import_tasks: update.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters