Ansibled PiHole
A couple of days ago I updated my PiHoles. Suddenly one of them stopped working. I spent some time to fix it, but to no avail, it just refused to start. I therefore installed a third one within 20 minutes and set it up, realizing that I maybe could automate this task. I therefore spent about 4 hours in total making this bootstrap and automation for adlist and whatnot. I later created a fourth PiHole and applied the playbook on it. The problem? PiHole uses sqlite for their automatic adlist with gravity, but there’s no clear way to add any lists through cli, at least not documented. Adding individual domains and regexes exists, for both white and black, but a list containing lots of domains does not.
After digging around, speculating having to install sqlite3 or accessing the webui API, I found that pihole-FTL has a sqlite3 command. I therefore applied INSERT OR IGNORE INTO
on each address and it worked without any issues. Sqlite is surprisingly idempotent iff the tables contain unique or primary keys.
What did I learn from this? Don’t. 🙂