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.7KB

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