-
Notifications
You must be signed in to change notification settings - Fork 0
/
site-mosquitto.yml
110 lines (99 loc) · 2.95 KB
/
site-mosquitto.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
#
#
#
---
- name: Init deploy
hosts: localhost
become: yes
become_user: root
connection: local
any_errors_fatal: true
gather_facts: no
tasks:
- debug:
msg:
- "**********************************************************************************"
- "============================== Start Deploying mosquitto ========================="
- "**********************************************************************************"
- name:
wait_for:
delay: 3
timeout: 0
- name: Gather system time
setup:
filter: ansible_date_time
- name: Set start time
set_fact:
time_start: "{{ ansible_date_time.epoch }}"
- debug: var=ansible_date_time.date
- debug: var=ansible_date_time.time
- name: mosquitto install
hosts: "{{ hosts | default('mosquitto-master,mosquitto-broker') }}"
gather_facts: no
become: yes
become_user: root
any_errors_fatal: true
roles:
- { role: set-default }
- { role: mosquitto }
- name: mosquitto broker configuration Files
hosts: "{{ hosts | default('mosquitto-broker') }}"
gather_facts: no
become: yes
become_user: root
any_errors_fatal: true
tasks:
- name: Adjusting mosquitto broker configuration Files
template:
src: "{{playbook_dir}}/roles/mosquitto/templates/{{ item }}.j2"
dest: "/etc/mosquitto/{{item}}"
force: yes
with_items:
- mosquitto.conf
- name: mosquitto start service
hosts: "{{ hosts | default('mosquitto-master,mosquitto-broker') }}"
gather_facts: no
become: yes
become_user: root
any_errors_fatal: true
tasks:
- name: Link to the file
register: linkfiledout
shell: "ln -s /usr/local/lib/libwebsockets.so.1 /usr/lib/libwebsockets.so.1"
changed_when: "'libwebsockets.so.1' not in linkfiledout.stdout"
failed_when: false
- debug:
msg: "{{linkfiledout.stdout}}"
- name: Effective configuration
shell: ldconfig
- name: Check dirs mosquitto-certs
file:
path: /etc/mosquitto/cert
state: directory
recurse: yes
- name: mosquito Rely pkg
copy:
src: "{{item}}"
dest: /etc/mosquitto/cert
with_fileglob:
- "{{playbook_dir}}/ansible/mosquitto/cert/*"
- name: start mosquitto
shell: /usr/local/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf -d
- name: Render detection script
template:
src: "{{playbook_dir}}/roles/mosquitto/templates/{{ item }}.j2"
dest: "{{target_dir}}/mosquitto/{{item}}"
force: yes
mode: 0755
with_items:
- Service_detect.sh
- name: Add rc.local execute permissions
file:
path: /etc/rc.d/rc.local
mode: 755
- name: Add mosquitto script to rc.local
lineinfile:
dest: /etc/rc.local
line: |
cd {{target_dir}}/mosquitto/ && bash Service_detect.sh
bash {{target_dir}}/mosquitto/Service_detect.sh