--- # Here I use "dependencies" in a loosely defined fashion # most of these packages would already be expected to be installed on any Ubuntu system # but, does not hurt to be thorough - name: Install dependencies (apt packages) become: true ansible.builtin.apt: name: "{{ pihole_apt_dependencies }}" state: present # https://github.com/gsemet/ansible-rpi-pihole/blob/master/roles/pi/tasks/main.yml # https://gist.github.com/bendews/e09edfc60e581ec4c686c4b70297f543 # https://github.com/Freekers/automated-pihole/blob/master/playbook.yml # After reading up a little, it seems clear that the regular Pi-Hole # install script will not work with Ansible by default. # And in several places, I've seen the pihole devs state thay they don't intend # to support Ansible playbooks. Fair enough. I've found suggested work-arounds: # https://github.com/drew-kun/ansible-pihole/blob/master/tasks/install.yml # https://discourse.pi-hole.net/t/automated-installation-enhancements-and-fixes/28746 # https://github.com/pi-hole/pi-hole/pull/3195 - name: "Clone the Pi-Hole repo" ansible.builtin.git: repo: "{{ __pihole_effective.repo.remote }}" dest: "{{ __pihole_effective.repo.path }}" version: "{{ __pihole_version }}" become: true become_user: "{{ ansible_user_id }}" register: __pihole_repo # what happens if we run the install script with a pre-existing pihole on the system? # is it overwritten without complaints from the installer? # what if the repo has an older version than the installed pihole? # would it perhaps by easiest to never allow install script to run if pihole is already installed? # on my machine the install script produced a never-ending output of "y" lines immediately after # successfully restarting the pihole-FTL service (if output was printed to file it quickly # filled the available disk space). Did this happen because Pi-Hole was already installed? - name: Run Pi-Hole installation script in unattended mode when: - (__pihole_repo.changed | bool) or (pihole_force_install | bool) or true # but not if pihole is already installed, in that case let the updater do its job - not (__pihole_installed | bool) block: # the unattended install only works if pihole.toml already exists (configure.yml) # debug tip: keep track of the install progress by tailing the log-file on the host in question - name: Run Pi-Hole installation script become: true ansible.builtin.shell: > {{ pihole_install_script }} --unattended >> {{ __pihole_effective.repo.path }}/pihole_install.log changed_when: true # can we create a task that tails -f the log file and then quits (continues to next task) # once no new tail output for X seconds? # https://stackoverflow.com/questions/33663357/how-to-continuously-tail-remote-files-using-ansible # https://github.com/ansible/ansible/issues/4870 # https://github.com/ansible/ansible/issues/3887 # https://github.com/ansible/proposals/issues/92 # Perhaps in lieu of tailing we could simply print pihole_install.log in the next task? - name: Ingest the Pi-Hole install log file ansible.builtin.slurp: src: "{{ __pihole_effective.repo.path }}/pihole_install.log" register: __pihole_install_log when: pihole_testing | bool # https://www.shellhacks.com/ansible-cat-file-print-read-file-content - name: Display the install log ansible.builtin.debug: msg: "{{ __pihole_install_log.content | b64decode }}" when: pihole_testing | bool # END OF BLOCK