From 146940773a286f9188394d3cb1ef95fcb9fa51a1 Mon Sep 17 00:00:00 2001 From: Sam Maes Date: Wed, 1 May 2019 14:23:11 +0200 Subject: [PATCH 1/2] Add mosquitto --- README.md | 1 + docs/applications/mosquitto.md | 13 ++++++ docs/configuration/application_ports.md | 2 + group_vars/all.yml.dist | 10 +++++ nas.yml | 4 ++ tasks/mosquitto.yml | 56 +++++++++++++++++++++++++ templates/mosquitto/mosquitto.conf | 6 +++ templates/traefik/traefik.toml | 1 + 8 files changed, 93 insertions(+) create mode 100644 docs/applications/mosquitto.md create mode 100644 tasks/mosquitto.yml create mode 100644 templates/mosquitto/mosquitto.conf diff --git a/README.md b/README.md index d61899b2..f69d44d0 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,7 @@ Ansible config and a bunch of Docker containers. * [Jackett](https://github.com/Jackett/Jackett) - API Support for your favorite torrent trackers * [MiniDlna](https://sourceforge.net/projects/minidlna/) - simple media server which is fully compliant with DLNA/UPnP-AV clients * [Miniflux](https://miniflux.app/) - An RSS news reader +* [Mosquitto](https://mosquitto.org) - An open source MQTT broker * [MyMediaForAlexa](https://www.mymediaalexa.com/) - Lets you stream your music collection to your alexa device * [Netdata](https://my-netdata.io/) - An extremely comprehensive system monitoring solution * [Nextcloud](https://nextcloud.com/) - A self-hosted Dropbox alternative diff --git a/docs/applications/mosquitto.md b/docs/applications/mosquitto.md new file mode 100644 index 00000000..2c167cf2 --- /dev/null +++ b/docs/applications/mosquitto.md @@ -0,0 +1,13 @@ +# Mosquitto + +Homepage: [https://mosquitto.org](https://mosquitto.org) + +Mosquitto is a lightweight open source MQTT message broker. + +## Usage + +Set `mosquitto_enabled: true` in your `group_vars/all.yml` file. + +## Specific Configuration + +You can change the mosquitto.conf template to change the default configuration. diff --git a/docs/configuration/application_ports.md b/docs/configuration/application_ports.md index f3f0569a..4b837b7f 100644 --- a/docs/configuration/application_ports.md +++ b/docs/configuration/application_ports.md @@ -20,6 +20,8 @@ By default, applications can be found on the ports listed below. | Jackett | 9117 | | | MiniDLNA | 8201 | | | Miniflux | 8070 | | +| Mosquitto | 1883 | MQTT | +| Mosquitto | 9001 | Websocket | | MyMediaForAlexa | 52051 | | | Netdata | 19999 | | | Nextcloud | 8080 | | diff --git a/group_vars/all.yml.dist b/group_vars/all.yml.dist index 000773e9..f73e2a69 100644 --- a/group_vars/all.yml.dist +++ b/group_vars/all.yml.dist @@ -64,6 +64,9 @@ thelounge_enabled: false # Password Management bitwarden_enabled: false +# MQTT +mosquitto_enabled: false + ### ### General ### @@ -525,3 +528,10 @@ bitwarden_admin_token: qwertyuiop1234567890poiuytrewq0987654321 # Once you have created your user, set to "false" and run one more time. # Target just Bitwarden by running: ansible-playbook -i inventory nas.yml -b -K -t bitwarden bitwarden_allow_signups: false + +### +### Mosquitto +### +mosquitto_available_externally: "false" +mosquitto_docker_image: eclipse-mosquitto:latest +mosquitto_data_directory: "{{ docker_home }}/mosquitto" diff --git a/nas.yml b/nas.yml index 428872f7..f3f93850 100644 --- a/nas.yml +++ b/nas.yml @@ -151,3 +151,7 @@ - import_tasks: tasks/bitwarden.yml when: (bitwarden_enabled | default(False)) tags: bitwarden + + - import_tasks: tasks/mosquitto.yml + when: (mosquitto_enabled | default(False)) + tags: mosquitto diff --git a/tasks/mosquitto.yml b/tasks/mosquitto.yml new file mode 100644 index 00000000..5cb425d4 --- /dev/null +++ b/tasks/mosquitto.yml @@ -0,0 +1,56 @@ +--- +- name: Create Mosquitto group + group: + name: mosquitto + gid: 1311 + state: present + +- name: Create Mosquitto user + user: + name: mosquitto + uid: 1311 + state: present + system: yes + update_password: on_create + create_home: no + group: mosquitto + +- name: Create Mosquitto Directories + file: + path: "{{ item }}" + state: directory + owner: mosquitto + group: mosquitto + with_items: + - "{{ mosquitto_data_directory }}/config" + - "{{ mosquitto_data_directory }}/data" + - "{{ mosquitto_data_directory }}/log" + +- name: Template mosquitto.conf + template: + src: mosquitto/mosquitto.conf + dest: "{{ mosquitto_data_directory }}/config/mosquitto.conf" + +- name: Create Mosquitto container + docker_container: + name: mosquitto + image: "{{ mosquitto_docker_image }}" + pull: true + volumes: + - "{{ mosquitto_data_directory }}:/config:rw" + - "{{ mosquitto_data_directory }}:/data:rw" + - "{{ mosquitto_data_directory }}:/log:rw" + env: + PUID: 1311 + PGID: 1311 + TZ: "{{ ansible_nas_timezone }}" + ports: + - "1883:1883" + - "9001:9001" + restart_policy: unless-stopped + memory: 1g + labels: + traefik.backend: "mosquitto" + traefik.frontend.rule: "Host:mosquitto.{{ ansible_nas_domain }}" + traefik.enable: "{{ mosquitto_available_externally }}" + traefik.port: "80" diff --git a/templates/mosquitto/mosquitto.conf b/templates/mosquitto/mosquitto.conf new file mode 100644 index 00000000..3da00a5f --- /dev/null +++ b/templates/mosquitto/mosquitto.conf @@ -0,0 +1,6 @@ +persistence true +persistence_location /mosquitto/data/ +log_dest file /mosquitto/log/mosquitto.log + +#listener 9001 +#protocol websockets diff --git a/templates/traefik/traefik.toml b/templates/traefik/traefik.toml index c863ecc3..3c92759d 100644 --- a/templates/traefik/traefik.toml +++ b/templates/traefik/traefik.toml @@ -191,6 +191,7 @@ onDemand = false # create certificate when container is created "heimdall.{{ ansible_nas_domain }}", "jackett.{{ ansible_nas_domain }}", "miniflux.{{ ansible_nas_domain }}", + "mosquitto.{{ ansible_nas_domain }}", "netdata.{{ ansible_nas_domain }}", "nextcloud.{{ ansible_nas_domain }}", "plex.{{ ansible_nas_domain }}", From 733b138367ba9f536294904ae87ed8a5f2d8d08c Mon Sep 17 00:00:00 2001 From: Sam Maes Date: Tue, 25 Jun 2019 19:26:16 +0200 Subject: [PATCH 2/2] mosquitto changes for PR --- docs/applications/mosquitto.md | 3 --- group_vars/all.yml.dist | 1 - tasks/mosquitto.yml | 26 +------------------------- templates/mosquitto/mosquitto.conf | 2 -- templates/traefik/traefik.toml | 1 - 5 files changed, 1 insertion(+), 32 deletions(-) diff --git a/docs/applications/mosquitto.md b/docs/applications/mosquitto.md index 2c167cf2..26da7021 100644 --- a/docs/applications/mosquitto.md +++ b/docs/applications/mosquitto.md @@ -8,6 +8,3 @@ Mosquitto is a lightweight open source MQTT message broker. Set `mosquitto_enabled: true` in your `group_vars/all.yml` file. -## Specific Configuration - -You can change the mosquitto.conf template to change the default configuration. diff --git a/group_vars/all.yml.dist b/group_vars/all.yml.dist index f73e2a69..f7041231 100644 --- a/group_vars/all.yml.dist +++ b/group_vars/all.yml.dist @@ -533,5 +533,4 @@ bitwarden_allow_signups: false ### Mosquitto ### mosquitto_available_externally: "false" -mosquitto_docker_image: eclipse-mosquitto:latest mosquitto_data_directory: "{{ docker_home }}/mosquitto" diff --git a/tasks/mosquitto.yml b/tasks/mosquitto.yml index 5cb425d4..1633f68f 100644 --- a/tasks/mosquitto.yml +++ b/tasks/mosquitto.yml @@ -1,26 +1,7 @@ ---- -- name: Create Mosquitto group - group: - name: mosquitto - gid: 1311 - state: present - -- name: Create Mosquitto user - user: - name: mosquitto - uid: 1311 - state: present - system: yes - update_password: on_create - create_home: no - group: mosquitto - - name: Create Mosquitto Directories file: path: "{{ item }}" state: directory - owner: mosquitto - group: mosquitto with_items: - "{{ mosquitto_data_directory }}/config" - "{{ mosquitto_data_directory }}/data" @@ -34,7 +15,7 @@ - name: Create Mosquitto container docker_container: name: mosquitto - image: "{{ mosquitto_docker_image }}" + image: eclipse-mosquitto:latest pull: true volumes: - "{{ mosquitto_data_directory }}:/config:rw" @@ -49,8 +30,3 @@ - "9001:9001" restart_policy: unless-stopped memory: 1g - labels: - traefik.backend: "mosquitto" - traefik.frontend.rule: "Host:mosquitto.{{ ansible_nas_domain }}" - traefik.enable: "{{ mosquitto_available_externally }}" - traefik.port: "80" diff --git a/templates/mosquitto/mosquitto.conf b/templates/mosquitto/mosquitto.conf index 3da00a5f..ce7c5910 100644 --- a/templates/mosquitto/mosquitto.conf +++ b/templates/mosquitto/mosquitto.conf @@ -2,5 +2,3 @@ persistence true persistence_location /mosquitto/data/ log_dest file /mosquitto/log/mosquitto.log -#listener 9001 -#protocol websockets diff --git a/templates/traefik/traefik.toml b/templates/traefik/traefik.toml index 3c92759d..c863ecc3 100644 --- a/templates/traefik/traefik.toml +++ b/templates/traefik/traefik.toml @@ -191,7 +191,6 @@ onDemand = false # create certificate when container is created "heimdall.{{ ansible_nas_domain }}", "jackett.{{ ansible_nas_domain }}", "miniflux.{{ ansible_nas_domain }}", - "mosquitto.{{ ansible_nas_domain }}", "netdata.{{ ansible_nas_domain }}", "nextcloud.{{ ansible_nas_domain }}", "plex.{{ ansible_nas_domain }}",