--- # For the unattended install to work as intended (i.e., unattended) pihole.toml must be in # place *before* the installer runs, so the role creates the pihole user and group itself. - name: Create system user and group (nologin shell) for {{ __pihole_effective.user }} become: true ansible.builtin.user: name: "{{ __pihole_effective.user }}" state: present system: true shell: /usr/sbin/nologin # this task requires the __pihole_effective.user user/group to exist, fails otherwise - name: Create Pi-Hole configuration directory become: true ansible.builtin.file: name: "{{ __pihole_effective.config.files.database | dirname }}" state: directory owner: "{{ __pihole_effective.user }}" group: "{{ __pihole_effective.group }}" mode: '0755' - name: Prepare Pi-Hole configuration (first-time installation) become: true ansible.builtin.template: src: pihole.toml.j2 dest: "{{ __pihole_effective.config.files.database | dirname }}/pihole.toml" owner: "{{ __pihole_effective.user }}" group: "{{ __pihole_effective.group }}" mode: '0644' when: - not (__pihole_installed | bool) - not ansible_check_mode or __pihole_config_dir.stat.exists notify: reconfigure pihole # the rendered file holds the password hashes and the TOTP secret no_log: true diff: false