First commit

This commit is contained in:
2025-06-09 23:32:10 -04:00
commit 863aaeabc7
92 changed files with 2992 additions and 0 deletions

4
ansible/pihole/.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
.ansible
inventory.ini
auth_body.json
secrets.yml

View 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"
}
}
}

View 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

View 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

View File

@@ -0,0 +1 @@
pihole_password: "SECRET"