Aucune description
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

mosquitto.yml 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. ---
  2. # Installs Mosquitto MQTT Broker
  3. - name: Install Mosquitto from official repository
  4. apt:
  5. name: "{{ packages }}"
  6. state: present
  7. update_cache: yes
  8. vars:
  9. packages:
  10. - mosquitto
  11. - mosquitto-clients
  12. tags:
  13. - dependencies
  14. - name: Configure Mosquitto
  15. template:
  16. src={{ item.src }}
  17. dest={{ item.dest }}
  18. owner=root
  19. group=root
  20. with_items:
  21. - { src: 'etc_mosquitto_conf.d_10-users.j2', dest: '/etc/mosquitto/conf.d/10-users.conf' }
  22. - { src: 'etc_mosquitto_conf.d_20-default.j2', dest: '/etc/mosquitto/conf.d/20-default.conf' }
  23. - { src: 'etc_mosquitto_conf.d_21-tls.j2', dest: '/etc/mosquitto/conf.d/21-tls.conf' }
  24. - { src: 'etc_mosquitto_conf.d_22-ws.j2', dest: '/etc/mosquitto/conf.d/22-ws.conf' }
  25. notify: restart mosquitto
  26. - name: Ensure mosquitto passwd file exists
  27. file: path=/etc/mosquitto/passwd state=touch
  28. - name: Create mosquitto users
  29. shell: mosquitto_passwd -b /etc/mosquitto/passwd {{ item.name }} {{ item.password }}
  30. with_items: "{{ mosquitto_users }}"
  31. - name: Set firewall rules for Mosquitto
  32. ufw: rule=allow port={{ item }} proto=tcp
  33. with_items:
  34. - 1883 # mqtt (only enable in private networks!)
  35. - 8883 # mqtts (+ ssl)
  36. - 8083 # mqtt websocket
  37. tags: ufw
  38. - name: Register new Mosquitto service
  39. systemd: name=mosquitto daemon_reload=yes enabled=yes
  40. - name: Start new Mosquitto instance
  41. service: name=mosquitto state=started