29 lines
751 B
YAML
29 lines
751 B
YAML
- 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
|