Skip to content

Commit 7d4de77

Browse files
authored
Added mosquitto server to ansible playbook (#10)
1 parent 53fbdd5 commit 7d4de77

File tree

4 files changed

+57
-3
lines changed

4 files changed

+57
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
listener 1883 0.0.0.0
2+
allow_anonymous false
3+
password_file /mosquitto/config/passwd

src/ansible/files/mosquitto/passwd

Whitespace-only changes.

src/ansible/inventory.yaml

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
webservers:
22
hosts:
33
srv501663.hstgr.cloud:
4-
ansible_user: root
4+
ansible_user: root
5+
6+
mosquitto:
7+
children:
8+
webservers:

src/ansible/playbook.yaml

+49-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
- name: Docker
33
hosts:
44
- webservers
5+
- mosquitto
56
roles:
67
# - geerlingguy.docker
78

8-
- name: Setup
9+
- name: Webserver-Setup
910
hosts:
1011
- webservers
1112
tasks:
@@ -78,4 +79,50 @@
7879
SECRET_KEY_FILE: "/etc/SECRET_KEY"
7980
STATIC_ROOT: "/data/static"
8081
MEDIA_ROOT: "/data/media"
81-
MEDIA_URL: "/media/"
82+
MEDIA_URL: "/media/"
83+
84+
- name: Mosquitto
85+
hosts:
86+
- mosquitto
87+
tasks:
88+
- name: Mosquitto Directory
89+
ansible.builtin.file:
90+
path: "{{ item }}"
91+
state: directory
92+
mode: 0700
93+
with_items:
94+
- /etc/mosquitto
95+
96+
- name: Mosquitto Config
97+
ansible.builtin.copy:
98+
src: mosquitto/mosquitto.conf
99+
dest: /etc/mosquitto/mosquitto.conf
100+
101+
- name: Mosquitto Passwords
102+
community.docker.docker_container:
103+
name: mqtt-passwd
104+
image: eclipse-mosquitto:latest
105+
detach: false
106+
command: "mosquitto_passwd -b /mosquitto/config/passwd {{ item.key }} {{ item.value }}"
107+
volumes:
108+
- "/etc/mosquitto/passwd:/mosquitto/config/passwd"
109+
no_log: true
110+
loop: "{{ mosquitto_users|dict2items }}"
111+
vars:
112+
mosquitto_users:
113+
gymkhana: !vault |
114+
$ANSIBLE_VAULT;1.1;AES256
115+
64343437653430373430303264633266303333656437636330346538333039363332313639356266
116+
6165393664646332303062343464653238616634353733340a363832633936383639396234303366
117+
63636362393437653834383564396136386337366362383066633864396131323564346436346365
118+
3130313466383865390a656231626331633835616530663234353739613731343935363062393164
119+
37623366643835333531393434666432623365666536393164363363646533386666
120+
121+
- name: Run Mosquitto
122+
community.docker.docker_container:
123+
name: mqtt
124+
image: eclipse-mosquitto:latest
125+
volumes:
126+
- "/etc/mosquitto/mosquitto.conf:/mosquitto/config/mosquitto.config"
127+
- "/etc/mosquitto/passwd:/mosquitto/config/passwd"
128+

0 commit comments

Comments
 (0)