First commit
This commit is contained in:
4
ansible/pihole/.gitignore
vendored
Normal file
4
ansible/pihole/.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
.ansible
|
||||
inventory.ini
|
||||
auth_body.json
|
||||
secrets.yml
|
||||
25
ansible/pihole/config.json
Normal file
25
ansible/pihole/config.json
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"config": {
|
||||
"dns": {
|
||||
"listeningMode": "local",
|
||||
"upstreams": [
|
||||
"8.8.8.8",
|
||||
"8.8.4.4",
|
||||
"9.9.9.10",
|
||||
"149.112.112.10",
|
||||
"1.1.1.1",
|
||||
"1.0.0.1"
|
||||
],
|
||||
"hosts": [
|
||||
|
||||
]
|
||||
},
|
||||
"dhcp": {
|
||||
"active": true,
|
||||
"start": "192.168.1.100",
|
||||
"end": "192.168.1.254",
|
||||
"router": "192.168.1.1",
|
||||
"netmask": "255.255.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
28
ansible/pihole/configure.yml
Normal file
28
ansible/pihole/configure.yml
Normal file
@@ -0,0 +1,28 @@
|
||||
- name: Configurar Pihole
|
||||
hosts: pihole
|
||||
become: false
|
||||
|
||||
tasks:
|
||||
- name: Autenticar la API de pihole
|
||||
ansible.builtin.uri:
|
||||
url: http://localhost/api/auth
|
||||
method: POST
|
||||
body: |
|
||||
{
|
||||
"password": "{{ pihole_password }}"
|
||||
}
|
||||
body_format: json
|
||||
return_content: true
|
||||
register: auth_response
|
||||
changed_when: false
|
||||
|
||||
- name: Extraer SID de la respuesta de autenticación
|
||||
ansible.builtin.set_fact:
|
||||
pihole_sid: "{{ auth_response.json.session.sid | urlencode }}"
|
||||
|
||||
- name: Configurar pihole
|
||||
ansible.builtin.uri:
|
||||
url: http://localhost/api/config?sid={{ pihole_sid }}
|
||||
method: PATCH
|
||||
src: config.json
|
||||
body_format: json
|
||||
43
ansible/pihole/install.yml
Normal file
43
ansible/pihole/install.yml
Normal file
@@ -0,0 +1,43 @@
|
||||
- name: Instalar pihole
|
||||
hosts: pihole
|
||||
become: true
|
||||
vars_files:
|
||||
- secrets.yml
|
||||
|
||||
tasks:
|
||||
- name: Actualizar e instalar paquetes
|
||||
ansible.builtin.apt:
|
||||
update_cache: true
|
||||
upgrade: true
|
||||
name:
|
||||
- curl
|
||||
|
||||
- name: Crear carpeta para archivo necesario para unattended
|
||||
ansible.builtin.file:
|
||||
path: /etc/pihole
|
||||
state: directory
|
||||
mode: '0755'
|
||||
|
||||
- name: Creando archivo necesario para unattended
|
||||
ansible.builtin.copy:
|
||||
content: ""
|
||||
dest: /etc/pihole/setupVars.conf
|
||||
force: false
|
||||
mode: '0755'
|
||||
|
||||
- name: Descargar script
|
||||
ansible.builtin.get_url:
|
||||
url: https://install.pi-hole.net
|
||||
dest: /tmp/install_pihole.sh
|
||||
mode: '0755'
|
||||
|
||||
- name: Instalar pihole
|
||||
ansible.builtin.command: /tmp/install_pihole.sh --unattended
|
||||
environment:
|
||||
PIHOLE_SKIP_OS_CHECK: "true"
|
||||
args:
|
||||
creates: '/usr/local/bin/pihole'
|
||||
|
||||
- name: Habilitar contraseña si no está configurada
|
||||
ansible.builtin.command: pihole setpassword {{ pihole_password }}
|
||||
changed_when: false
|
||||
1
ansible/pihole/secrets.yml.example
Normal file
1
ansible/pihole/secrets.yml.example
Normal file
@@ -0,0 +1 @@
|
||||
pihole_password: "SECRET"
|
||||
Reference in New Issue
Block a user