Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added mosquitto server to ansible playbook #10

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/ansible/files/mosquitto/mosquitto.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
listener 1883 0.0.0.0
allow_anonymous false
password_file /mosquitto/config/passwd
Empty file.
6 changes: 5 additions & 1 deletion src/ansible/inventory.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
webservers:
hosts:
srv501663.hstgr.cloud:
ansible_user: root
ansible_user: root

mosquitto:
children:
webservers:
51 changes: 49 additions & 2 deletions src/ansible/playbook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
- name: Docker
hosts:
- webservers
- mosquitto
roles:
# - geerlingguy.docker

- name: Setup
- name: Webserver-Setup
hosts:
- webservers
tasks:
Expand Down Expand Up @@ -78,4 +79,50 @@
SECRET_KEY_FILE: "/etc/SECRET_KEY"
STATIC_ROOT: "/data/static"
MEDIA_ROOT: "/data/media"
MEDIA_URL: "/media/"
MEDIA_URL: "/media/"

- name: Mosquitto
hosts:
- mosquitto
tasks:
- name: Mosquitto Directory
ansible.builtin.file:
path: "{{ item }}"
state: directory
mode: 0700
with_items:
- /etc/mosquitto

- name: Mosquitto Config
ansible.builtin.copy:
src: mosquitto/mosquitto.conf
dest: /etc/mosquitto/mosquitto.conf

- name: Mosquitto Passwords
community.docker.docker_container:
name: mqtt-passwd
image: eclipse-mosquitto:latest
detach: false
command: "mosquitto_passwd -b /mosquitto/config/passwd {{ item.key }} {{ item.value }}"
volumes:
- "/etc/mosquitto/passwd:/mosquitto/config/passwd"
no_log: true
loop: "{{ mosquitto_users|dict2items }}"
vars:
mosquitto_users:
gymkhana: !vault |
$ANSIBLE_VAULT;1.1;AES256
64343437653430373430303264633266303333656437636330346538333039363332313639356266
6165393664646332303062343464653238616634353733340a363832633936383639396234303366
63636362393437653834383564396136386337366362383066633864396131323564346436346365
3130313466383865390a656231626331633835616530663234353739613731343935363062393164
37623366643835333531393434666432623365666536393164363363646533386666

- name: Run Mosquitto
community.docker.docker_container:
name: mqtt
image: eclipse-mosquitto:latest
volumes:
- "/etc/mosquitto/mosquitto.conf:/mosquitto/config/mosquitto.config"
- "/etc/mosquitto/passwd:/mosquitto/config/passwd"

Loading