I want to add the install of pi-hole as part of a post-installatie script.
It would be great if I could pass some arguments to the script with some options or the command to default to standard options. In the docs, I cannot find how to do this. Any help would be welcome!!
You can create the setupVars.conf file under /etc/pihole
and then run the installer. What kind of options are you looking for?
Really glad to hear this is possible.
At minimum, I would like to have an install ready to run and I can configure later on. Ideally, I would like to pass all the setup options the script asks me for to the installer.
Where is setupvars.conf documented?
We have a few "undocumented" unattended flags.
Come to think of it, I don't think we have this documented anywhere...I have added it to my list of things to do.
I would ask that you please create a feature request for this (or just edit the title and category to turn it into one) so other users can vote on it.
Just to expand on this, create /etc/pihole/setupVars.conf
(as is now documented here)
Then you should be able to run
curl -L https://install.pi-hole.net | bash /dev/stdin --unattended
The script will consume the variables you have set in setupVars.conf
instead of asking you for new ones.
Excellent Gentlemen.
This is exactly what i wanted. I will try it this evening. Thank you for the fantastic work and the more than timely response.
Keep it up!
PS, I don't necessarily need a feature to pass options though the install command, but others might. Would you still like me to create a feature request?
No, I think we can accomplish most of what people need by editing setupVars.conf
, so we don't necessarily need a feature request for it.
Just reporting back that this worked exactly as I hoped. The only change I made is I added sudo before the bash command as I do not expect the script to allways be run as root.
curl -L https://install.pi-hole.net | sudo bash /dev/stdin --unattended
thank you for the excellent help.
You're welcome. Glad it's working for you.
I want to thank the development team for the --unattended
option.
I manually setup a pihole, then downloaded the setupConf.vars
Then created from it an ansible template and a ansible role to automate the installation.
I ran this command , and still it prompted and nothing was unattended
just to verify: you also created a file /etc/pihole/setupVars.conf and configured it using these values?
Hi realtebo I was also thinking to create an ansible module to do the installation.
Can you share your ansible code?
Just in case somebody is interested in an example of an unattended installation with Ansible.
Enable lighttp if you want to use it (and remove the --disable-web-server). I'm using apache...
Your contents of setupVars.conf may vary. There still seems no complete documentation about the possible variables.
adlists.list contains all filter lists you want to activate while installing. Each URL in one line.
You should check the setupVars.conf from time to time to find "new" options and update the playbook to include them in the next installation.
Make sure to set the variables to match your needs.
- name: Create pihole group
group:
name: pihole
state: present
tags:
- pihole
- name: Create pihole user
user:
name: pihole
group: pihole
create_home: false
shell: /usr/sbin/nologin
state: present
tags:
- pihole
- name: Create /etc/pihole directory
file:
path: /etc/pihole
state: directory
owner: pihole
group: pihole
mode: '0775'
tags:
- pihole
- name: Create /etc/dnsmasq.d directory
file:
path: /etc/dnsmasq.d
state: directory
owner: root
group: root
mode: '0755'
# you might not need this
- name: Create custom IPv6 reverse config in /etc/dnsmasq.d/02-custom.conf
copy:
dest: /etc/dnsmasq.d/02-custom.conf
owner: root
group: root
mode: '0644'
content: |
# custom config, add another revers server for IPv6 addresses (local router box)
server=/0.0.0.0.0.0.0.0.0.0.d.f.ip6.arpa/{{ router_ipv6_ula_address }}
register: copy_dnsmasq
- name: Check if /etc/pihole/setupVars.conf already exists
stat:
path: /etc/pihole/setupVars.conf
register: setupvars
- name: Generate pihole setupVars.conf (overwrite with -e overwrite_setupvars=true )
copy:
dest: /etc/pihole/setupVars.conf
owner: root
group: root
mode: '0644'
backup: true
content: |
WEBPASSWORD={{ pihole_admin_password | hash('sha256') | hash('sha256') }}
PIHOLE_INTERFACE=eth0
IPV4_ADDRESS=192.168.x.y/24
IPV6_ADDRESS=fd00::2
QUERY_LOGGING=true
INSTALL_WEB_INTERFACE=true
LIGHTTPD_ENABLED=false
INSTALL_WEB_SERVER=false
DNSMASQ_LISTENING=single
PIHOLE_DNS_1=8.8.8.8
PIHOLE_DNS_2=8.8.4.4
PIHOLE_DNS_3=2001:4860:4860:0:0:0:0:8888
PIHOLE_DNS_4=2001:4860:4860:0:0:0:0:8844
DNS_FQDN_REQUIRED=true
DNS_BOGUS_PRIV=true
DNSSEC=false
TEMPERATUREUNIT=C
WEBUIBOXEDLAYOUT=traditional
API_EXCLUDE_DOMAINS=
API_EXCLUDE_CLIENTS=
API_QUERY_LOG_SHOW=all
API_PRIVACY_MODE=false
BLOCKING_ENABLED=true
REV_SERVER=true
REV_SERVER_CIDR=192.168.x.0/24
REV_SERVER_TARGET=192.168.x.z
REV_SERVER_DOMAIN=your.domain
CACHE_SIZE=10000
when: (setupvars.stat.exists == false ) or (( overwrite_setupvars is defined ) and ( overwrite_setupvars == "true" ))
register: copy_setupvars
- name: Generate adlist file for unattended installation
lineinfile:
dest: /etc/pihole/adlists.list
create: true
line: '{{ item }}'
with_items: '{{ pihole_adlists }}'
register: copy_adlists
- name: Check if pihole already installed
stat:
path: /usr/local/bin/pihole
register: pihole_installed
# PIHOLE_SKIP_OS_CHECK=true because Raspian 12 is not a supported platform yet. Remove after it is!
# Executing the setup when it's already installed, does not break the setup, but just eats a lot of time and does the same as pihole -r
- name: Install pihole in unattended mode. This might take some time!
shell: 'curl -L https://install.pi-hole.net | PIHOLE_SKIP_OS_CHECK=true bash /dev/stdin --unattended --disable-install-webserver'
when: ( pihole_installed.stat.exists == false ) or
( copy_setupvars.changed ) or
( copy_dnsmasq.changed ) or
( copy_adlists.changed )
This topic was automatically closed after 10 days. New replies are no longer allowed.