-
Notifications
You must be signed in to change notification settings - Fork 0
/
automation.yml
301 lines (276 loc) · 7.55 KB
/
automation.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
---
- name: Install MQTT Broker
remote_user: ansible
become: true
hosts: docker_nas
tasks:
- name: Ensure Mosquitto config paths exist
tags:
- mqtt
- docker
file:
path: "{{ item }}"
state: directory
with_items:
- /volume2/docker/mosquitto/config
- /volume2/docker/mosquitto/config/mosquitto.d
- /volume2/docker/mosquitto/data
- /volume2/docker/mosquitto/log
- name: Deploy Mosquitto configuration
tags:
- mqtt
- docker
template:
src: automation/mosquitto.conf.j2
dest: /volume2/docker/mosquitto/config/mosquitto.conf
owner: root
group: root
mode: 0644
register: mqtt_config
- name: Deploy Mosquitto container
tags:
- mqtt
- docker
docker_container:
name: mosquitto
image: eclipse-mosquitto
pull: "{{ update_containers | default(false) }}"
restart_policy: unless-stopped
published_ports:
- '1883:1883'
volumes:
- /volume2/docker/mosquitto/config:/mosquitto/config
- name: Restart Mosquitto container
tags:
- mqtt
- docker
docker_container:
name: mosquitto
state: restart
when: mqtt_config.changed
###################################################################
- name: Install Caller ID Server
remote_user: ansible
become: true
hosts: rpi-util1.core.home.gatwards.org
tasks:
- name: Configure NCIDd
tags:
- ncid
- automation
import_role:
name: ansible-role-ncid
- name: Update firewall rules (ports)
tags:
- ncid
- automation
- firewall
firewalld:
port: "{{ item }}"
immediate: yes
permanent: yes
state: enabled
with_items:
- 3333/tcp
#####################################################################
# # Nginx SSL proxy to provide an auth layer for inbound Internet traffic
# - name: Install nginx
# remote_user: ansible
# become: true
# hosts: automation
# tasks:
# - name: Install nginx
# import_role:
# name: ansible-role-nginx
# tags:
# - automation
# - nginx
# vars:
# nginx_yum_repo_enabled: false
# nginx_vhosts:
# - listen: "7443 ssl http2"
# server_name: "{{ ansible_fqdn }}"
# extra_parameters: |
# location / {
# proxy_pass http://localhost:8080/;
# proxy_set_header Host $http_host;
# proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_set_header X-Forwarded-Proto $scheme;
# }
# ssl_session_cache shared:SSL:10m;
# ssl_session_timeout 1h;
# ssl_session_tickets on;
# ssl_certificate "{{ ssl_dir }}/certs/{{ ansible_fqdn }}.pem";
# ssl_certificate_key "{{ ssl_dir }}/private/{{ ansible_fqdn }}.key";
# ssl_protocols TLSv1.2;
# ssl_ciphers EECDH+AESGCM:EDH+AESGCM:!ADH:!AECDH:!MD5;
# ssl_prefer_server_ciphers on;
# add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
# - name: Install OpenHAB
# remote_user: ansible
# become: true
# hosts: automation
# vars_files:
# - vault.yml
# tasks:
# - import_role:
# name: ansible-role-openhab
# tags:
# - automation
# - openhab
# - config
# vars:
# # Get sensitive vars from the vault
# openhab_keystore_password: "{{ vault_openhab_keystore_password }}"
# openhab_voicerss_api_key: "{{ vault_openhab_voicerss_api_key }}"
# openhab_zwave_securitykey: "{{ vault_openhab_zwave_securitykey }}"
# openhab_solaredge_api_key: "{{ vault_openhab_solaredge_api_key }}"
# openhab_solaredge_siteId: "{{ vault_openhab_solaredge_siteId }}"
# openhab_pushover_api_key: "{{ vault_openhab_pushover_api_key }}"
# openhab_pushover_user_key1: "{{ vault_openhab_pushover_user_key1 }}"
# openhab_sonos_ids:
# livingroom: "{{ vault_sonos_livingroom }}"
# alfresco: "{{ vault_sonos_alfresco }}"
# portable1: "{{ vault_sonos_portable1 }}"
# openhab_audio_sink: "sonos:CONNECTAMP:{{ openhab_sonos_ids.livingroom }}"
# openhab_latlon: "{{ latitude }},{{ longitude }}"
# openhab_mqtt_broker_fqdn: mqtt.iot.home.gatwards.org
# openhab_influxdb_host: influxdb.iot.home.gatwards.org
# openhab_influxdb_db: 'openhab'
# openhab_elk_ip: 172.22.2.10
# # OpenHAB Base configuration - addons.cfg
# openhab_package: expert
# openhab_bindings:
# - astro
# - expire1
# - gpstracker
# - mqtt
# - network
# - ntp
# - solaredge
# - sonos
# - tcp1
# - zwave
# openhab_ui:
# - basic
# - paper
# - habmin
# - habpanel
# - homebuilder
# openhab_action:
# - pushover
# openhab_persistence:
# - mapdb
# - influxdb
# openhab_transformation:
# - javascript
# - jsonpath
# - map
# - regex
# openhab_voice:
# - voicerss
# openhab_misc:
# - market
# - name: Open Firewall Ports
# tags:
# - automation
# - openhab
# - firewall
# firewalld:
# port: "{{ item }}"
# immediate: yes
# permanent: yes
# state: enabled
# with_items:
# - 8080/tcp
# - 8443/tcp
# - 7443/tcp
# - 1900/udp
# - 5007/tcp
# - name: Open Firewall Services
# tags:
# - automation
# - openhab
# - firewall
# firewalld:
# service: "{{ item }}"
# immediate: yes
# permanent: yes
# state: enabled
# with_items:
# - upnp-client
# - name: Add rich-rule to allow Sonos uPNP
# tags:
# - automation
# - openhab
# - firewall
# firewalld:
# rich_rule: 'rule family="ipv4" source address="172.22.1.0/24" destination address="239.255.255.250/32" port port="1900" protocol="udp" accept'
# immediate: yes
# permanent: yes
# state: enabled
# # - name: Add rule to allow DHCP proxy listener
# # tags:
# # - automation
# # - openhab
# # - firewall
# # firewalld:
# # port: "{{ item }}"
# # immediate: yes
# # permanent: yes
# # state: enabled
# # with_items:
# # - 6767/udp
#####################################################################
- name: Install Custom Scripting
remote_user: ansible
become: true
hosts: automation
tasks:
- name: Install custom script requirements
tags:
- automation
- customscript
package:
name: "{{ packages }}"
state: present
vars:
packages:
- python3-yaml
- name: Deploy custom scripts
tags:
- automation
- customscript
template:
src: files/automation/{{ item }}
dest: /usr/local/bin/{{ item }}
mode: '0755'
with_items:
- bomxml2mqtt.py
- name: Deploy custom script configs
tags:
- automation
- customscript
template:
src: templates/automation/{{ item }}.j2
dest: /usr/local/etc/{{ item }}
mode: '0644'
with_items:
- bomxml2mqtt.yml
vars:
bomxml2mqtt_bomuri: ftp://ftp.bom.gov.au/anon/gen/fwo/IDN11060.xml
bomxml2mqtt_topic: weather/bomxml/
bomxml2mqtt_user: bomxml
bomxml2mqtt_pass: 'notused'
- name: Deploy custom crontabs
tags:
- automation
- customscript
cron:
name: bomxml
cron_file: bomxml
user: root
job: '/usr/local/bin/bomxml2mqtt.py >/dev/null 2>&1'
minute: '02'
hour: '0,3,6,9,12,15,18,21'