mirror of
https://github.com/iiab/iiab.git
synced 2025-03-09 15:40:17 +00:00
mosquitto - iiab_installed
This commit is contained in:
parent
14f4e27e68
commit
9748669a1b
3 changed files with 63 additions and 44 deletions
21
roles/mosquitto/tasks/enable.yml
Normal file
21
roles/mosquitto/tasks/enable.yml
Normal file
|
@ -0,0 +1,21 @@
|
|||
- name: Enable & Start 'mosquitto' service
|
||||
systemd:
|
||||
daemon_reload: yes
|
||||
name: mosquitto
|
||||
enabled: yes
|
||||
state: started
|
||||
when: mosquitto_enabled | bool
|
||||
|
||||
- name: Add 'mosquitto' variable values to {{ iiab_ini_file }}
|
||||
ini_file:
|
||||
path: "{{ iiab_ini_file }}"
|
||||
section: mosquitto
|
||||
option: "{{ item.option }}"
|
||||
value: "{{ item.value }}"
|
||||
with_items:
|
||||
- option: name
|
||||
value: Mosquitto service
|
||||
- option: description
|
||||
value: Mosquitto service
|
||||
- option: mosquitto_enabled
|
||||
value: "{{ mosquitto_enabled }}"
|
38
roles/mosquitto/tasks/install.yml
Normal file
38
roles/mosquitto/tasks/install.yml
Normal file
|
@ -0,0 +1,38 @@
|
|||
- name: "Install packages: mosquitto, mosquitto-clients"
|
||||
package:
|
||||
name: "{{ item }}"
|
||||
state: present
|
||||
with_items:
|
||||
- mosquitto
|
||||
- mosquitto-clients
|
||||
tags: download
|
||||
|
||||
- name: Disable & Stop 'mosquitto' service
|
||||
systemd:
|
||||
name: mosquitto
|
||||
enabled: no
|
||||
state: stopped
|
||||
|
||||
- name: Create (touch) file /etc/mosquitto/passwd
|
||||
file:
|
||||
path: /etc/mosquitto/passwd
|
||||
state: touch
|
||||
mode: "u=rw,g=r,o=r" # 0644
|
||||
|
||||
- name: Populate /etc/mosquitto/passwd with actual username/password
|
||||
shell: mosquitto_passwd -b /etc/mosquitto/passwd "{{ mosquitto_user }}" "{{ mosquitto_password }}"
|
||||
|
||||
- name: Install /etc/mosquitto/conf.d/websockets.conf from template
|
||||
template:
|
||||
src: websockets.conf.j2
|
||||
dest: /etc/mosquitto/conf.d/websockets.conf
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0755
|
||||
|
||||
- name: Add 'mosquitto_installed' variable values to {{ iiab_installed }}
|
||||
lineinfile:
|
||||
dest: "{{ iiab_installed }}"
|
||||
regexp: '^mosquitto_installed'
|
||||
line: 'mosquitto_installed'
|
||||
state: present
|
|
@ -1,45 +1,5 @@
|
|||
- name: "Install packages: mosquitto, mosquitto-clients"
|
||||
package:
|
||||
name: "{{ item }}"
|
||||
state: present
|
||||
with_items:
|
||||
- mosquitto
|
||||
- mosquitto-clients
|
||||
when: mosquitto_install | bool
|
||||
tags: download
|
||||
- include_tasks: install.yml
|
||||
when: mosquitto_install | bool and not mosquitto_installed is defined
|
||||
|
||||
- name: Disable & Stop 'mosquitto' service
|
||||
systemd:
|
||||
name: mosquitto
|
||||
enabled: no
|
||||
state: stopped
|
||||
when: mosquitto_install | bool
|
||||
|
||||
- name: Create (touch) file /etc/mosquitto/passwd
|
||||
file:
|
||||
path: /etc/mosquitto/passwd
|
||||
state: touch
|
||||
mode: "u=rw,g=r,o=r" # 0644
|
||||
when: mosquitto_install | bool
|
||||
|
||||
- name: Populate /etc/mosquitto/passwd with actual username/password
|
||||
shell: mosquitto_passwd -b /etc/mosquitto/passwd "{{ mosquitto_user }}" "{{ mosquitto_password }}"
|
||||
when: mosquitto_install | bool
|
||||
|
||||
- name: Install /etc/mosquitto/conf.d/websockets.conf from template
|
||||
template:
|
||||
backup: yes
|
||||
src: websockets.conf.j2
|
||||
dest: /etc/mosquitto/conf.d/websockets.conf
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0755
|
||||
when: mosquitto_install | bool
|
||||
|
||||
- name: Enable & Start 'mosquitto' service
|
||||
systemd:
|
||||
daemon_reload: yes
|
||||
name: mosquitto
|
||||
enabled: yes
|
||||
state: started
|
||||
when: mosquitto_enabled | bool
|
||||
- include_tasks: enable.yml
|
||||
when: mosquitto_install | bool or mosquitto_installed is defined
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue