aboutsummaryrefslogtreecommitdiff
path: root/roles/services/containers/home_assistant
diff options
context:
space:
mode:
Diffstat (limited to 'roles/services/containers/home_assistant')
-rw-r--r--roles/services/containers/home_assistant/handlers/main.yml4
-rw-r--r--roles/services/containers/home_assistant/tasks/main.yml86
2 files changed, 90 insertions, 0 deletions
diff --git a/roles/services/containers/home_assistant/handlers/main.yml b/roles/services/containers/home_assistant/handlers/main.yml
new file mode 100644
index 0000000..5463835
--- /dev/null
+++ b/roles/services/containers/home_assistant/handlers/main.yml
@@ -0,0 +1,4 @@
1- name: restart nginx
2 service:
3 name: nginx
4 state: restarted
diff --git a/roles/services/containers/home_assistant/tasks/main.yml b/roles/services/containers/home_assistant/tasks/main.yml
new file mode 100644
index 0000000..b44c529
--- /dev/null
+++ b/roles/services/containers/home_assistant/tasks/main.yml
@@ -0,0 +1,86 @@
1- name: set image fact
2 set_fact:
3 image: homeassistant/home-assistant:2023.6.3
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 home_assistant directory
13 file:
14 path: "{{ docker_home }}/home_assistant"
15 state: directory
16 owner: "{{ docker_username }}"
17 group: "{{ docker_username }}"
18 mode: '0755'
19
20- name: create config directory
21 file:
22 path: "{{ docker_home }}/home_assistant/config"
23 state: directory
24 owner: "{{ docker_username }}"
25 group: "{{ docker_username }}"
26 mode: '0755'
27
28- name: deploy configuration
29 copy:
30 src: "{{ home_assistant_config }}"
31 dest: "{{ docker_home }}/home_assistant/config/configuration.yaml"
32 owner: "{{ docker_username }}"
33 group: "{{ docker_username }}"
34 mode: '0644'
35
36- name: create home_assistant network
37 become: yes
38 become_user: "{{ docker_username }}"
39 docker_network:
40 name: "{{ home_assistant_network_name }}"
41 docker_host: "unix://run/user/{{ docker_uid }}/docker.sock"
42 driver: bridge
43 ipam_config:
44 - subnet: "{{ home_assistant_subnet }}"
45 gateway: "{{ home_assistant_gateway }}"
46
47- name: create and deploy home_assistant container
48 become: yes
49 become_user: "{{ docker_username }}"
50 environment:
51 XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}"
52 docker_container:
53 name: "home_assistant"
54 hostname: "home_assistant"
55 image: "{{ image }}"
56 docker_host: "unix://run/user/{{ docker_uid }}/docker.sock"
57 purge_networks: yes
58 networks:
59 - name: "{{ home_assistant_network_name }}"
60 ipv4_address: "{{ home_assistant_ipv4 }}"
61 ports:
62 - "127.0.0.1:{{ home_assistant_external_port }}:8123"
63 volumes:
64 - "{{ docker_home }}/home_assistant/config:/config"
65 env:
66 "TZ": "{{ timezone }}"
67 state: 'started'
68 recreate: yes
69 restart_policy: unless-stopped
70
71- name: deploy nginx configuration
72 notify: restart nginx
73 template:
74 src: "{{ home_assistant_nginx_config }}"
75 dest: /etc/nginx/sites-available/home_assistant.conf
76 owner: root
77 group: root
78 mode: '0644'
79
80- name: symlink site
81 file:
82 src: /etc/nginx/sites-available/home_assistant.conf
83 dest: /etc/nginx/sites-enabled/home_assistant.conf
84 owner: root
85 group: root
86 state: link