aboutsummaryrefslogtreecommitdiff
path: root/roles/services/containers/pihole_exporter
diff options
context:
space:
mode:
Diffstat (limited to 'roles/services/containers/pihole_exporter')
-rw-r--r--roles/services/containers/pihole_exporter/tasks/main.yml97
1 files changed, 97 insertions, 0 deletions
diff --git a/roles/services/containers/pihole_exporter/tasks/main.yml b/roles/services/containers/pihole_exporter/tasks/main.yml
new file mode 100644
index 0000000..4c52dc7
--- /dev/null
+++ b/roles/services/containers/pihole_exporter/tasks/main.yml
@@ -0,0 +1,97 @@
1- name: set image fact
2 set_fact:
3 image: ekofr/pihole-exporter:v0.4.0
4
5- name: set other facts
6 vars:
7 array: "{{ image.split('/', 1) }}"
8 set_fact:
9 repo_tag: "{{ array.1 }}"
10 custom_registry: "{{ docker_registry_url + '/' + docker_registry_username }}"
11
12- name: create pihole_exporter directory
13 file:
14 path: "{{ docker_home }}/pihole_exporter"
15 state: directory
16 owner: "{{ docker_username }}"
17 group: "{{ docker_username }}"
18 mode: '0755'
19
20- name: login to docker registry
21 become: yes
22 become_user: "{{ docker_username }}"
23 environment:
24 XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}"
25 docker_login:
26 docker_host: "unix://run/user/{{ docker_uid }}/docker.sock"
27 registry_url: "{{ docker_registry_url }}"
28 username: "{{ docker_registry_username }}"
29 password: "{{ docker_registry_password }}"
30
31- name: get pihole_exporter image
32 become: yes
33 become_user: "{{ docker_username }}"
34 environment:
35 XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}"
36 docker_image:
37 name: "{{ image }}"
38 repository: "{{ custom_registry }}/{{ repo_tag }}"
39 docker_host: "unix://run/user/{{ docker_uid }}/docker.sock"
40 source: pull
41 force_source: yes
42 push: yes
43
44- name: create pihole_exporter docker network
45 become: yes
46 become_user: "{{ docker_username }}"
47 docker_network:
48 name: "{{ pihole_exporter_network_name }}"
49 docker_host: "unix://run/user/{{ docker_uid }}/docker.sock"
50 driver: bridge
51 ipam_config:
52 - subnet: "{{ pihole_exporter_subnet }}"
53 gateway: "{{ pihole_exporter_gateway }}"
54
55- name: create and deploy pihole_exporter container
56 become: yes
57 become_user: "{{ docker_username }}"
58 environment:
59 XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}"
60 docker_container:
61 name: "pihole_exporter"
62 hostname: "pihole_exporter"
63 image: "{{ custom_registry }}/{{ repo_tag }}"
64 pull: yes
65 docker_host: "unix://run/user/{{ docker_uid }}/docker.sock"
66 purge_networks: yes
67 networks:
68 - name: "{{ pihole_exporter_network_name }}"
69 ports:
70 - "127.0.0.1:9617:9617"
71 state: 'started'
72 recreate: yes
73 restart_policy: unless-stopped
74 env:
75 "PIHOLE_HOSTNAME": "{{ pihole_ip }}"
76 "PIHOLE_API_TOKEN": "{{ pihole_api_token }}"
77 "PORT": "{{ pihole_api_port }}"
78 cap_drop:
79 - all
80
81- name: deploy nginx configuration
82 notify: restart nginx
83 register: nginx_config
84 copy:
85 src: "{{ pihole_exporter_nginx_config }}"
86 dest: /etc/nginx/sites-available/pihole-exporter.conf
87 owner: root
88 group: root
89 mode: '0644'
90
91- name: symlink site
92 file:
93 src: /etc/nginx/sites-available/pihole-exporter.conf
94 dest: /etc/nginx/sites-enabled/pihole-exporter.conf
95 owner: root
96 group: root
97 state: link