-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy_config.yml
90 lines (83 loc) · 2.95 KB
/
deploy_config.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
- hosts: home_assistant
remote_user: "{{ hass_remote_user|default('root') }}"
vars:
home_assistant_container: "home_assistant"
restart_home_assistant_enabled: no
deploy_gcp_cfg: true
deploy_google_account: false
tasks:
- name: "Deploy home assistant automation templates"
become: yes
template:
src: "{{ item.src }}"
dest: "{{ home_assistant_cfg_dir }}/automation/{{ item.path }}"
owner: "{{ home_assistant_user }}"
group: "{{ home_assistant_user }}"
block_start_string: "{{ item.block_start | default('<%') }}"
block_end_string: "{{ item.block_end | default('%>') }}"
variable_start_string: "{{ item.variable_start | default('<<') }}"
variable_end_string: "{{ item.variable_end | default('>>') }}"
with_filetree: "automation"
tags:
- hass_deploy_cfg
- hass_deploy_automations
notify:
- Check homeassistant config
- Restart home assistant
- name: "Deploy home assistant config templates"
become: yes
template:
src: "{{ item }}"
dest: "{{ home_assistant_cfg_dir }}/{{ item | basename }}"
owner: "{{ home_assistant_user }}"
group: "{{ home_assistant_user }}"
block_start_string: "{{ item.block_start | default('<%') }}"
block_end_string: "{{ item.block_end | default('%>') }}"
variable_start_string: "{{ item.variable_start | default('<<') }}"
variable_end_string: "{{ item.variable_end | default('>>') }}"
with_fileglob: "*.yaml"
tags:
- hass_deploy_cfg
- hass_deploy_core
notify:
- Check homeassistant config
- Restart home assistant
- name: "Deploy home assistant secrets template"
become: yes
template:
src: "secrets.yaml.j2"
dest: "{{ home_assistant_cfg_dir }}/secrets.yaml"
no_log: True
tags:
- hass_deploy_cfg
- hass_deploy_secrets
notify:
- Check homeassistant config
- Restart home assistant
- name: "Copy google service account file"
become: yes
copy:
src: google_service_account.json
dest: "{{ home_assistant_cfg_dir }}/google_service_account.json"
when:
- deploy_gcp_cfg|bool
- deploy_google_account|bool
notify:
- Check homeassistant config
- Restart home assistant
handlers:
- name: Check homeassistant config
become: yes
command: "docker exec {{ hass_docker_name }} python -m homeassistant --script check_config -c /config"
register: hass_config_check
notify: Assert config
- name: Assert config
assert:
that:
- "'ERROR' not in hass_config_check.stdout"
msg: "Config check reported error: {{ hass_config_check.stdout }}"
- name: Restart home assistant
become: yes
shell: "docker restart {{ home_assistant_container }}"
when:
- restart_home_assistant_enabled|bool