--- - name: Install Pi-hole dependencies ansible.builtin.apt: name: - curl - git - libcap2-bin - dns-root-data state: present update_cache: true - name: Create Pi-hole config directory ansible.builtin.file: path: /etc/pihole state: directory mode: "0755" - name: Write Pi-hole setup vars ansible.builtin.template: src: setupVars.conf.j2 dest: /etc/pihole/setupVars.conf mode: "0644" - name: Check if Pi-hole is already installed ansible.builtin.stat: path: /usr/local/bin/pihole register: pihole_binary - name: Download Pi-hole installer ansible.builtin.get_url: url: https://install.pi-hole.net dest: /tmp/pihole-install.sh mode: "0755" when: not pihole_binary.stat.exists - name: Run Pi-hole unattended installer ansible.builtin.command: cmd: /tmp/pihole-install.sh --unattended creates: /usr/local/bin/pihole when: not pihole_binary.stat.exists - name: Set Pi-hole web password ansible.builtin.command: cmd: /usr/local/bin/pihole setpassword "{{ pihole_password }}" changed_when: true - name: Set local DNS hosts in pihole.toml ansible.builtin.template: src: update_hosts.py.j2 dest: /tmp/pihole_update_hosts.py mode: "0755" notify: Update pihole hosts - name: Ensure pihole-FTL is running ansible.builtin.service: name: pihole-FTL state: started enabled: true