xoxys.mosquitto/tasks/install.yml
2017-12-17 14:20:03 +01:00

76 lines
1.7 KiB
YAML

---
- name: Add yum repository
yum_repository:
name: mttq
file: mttq
description: MTTQ Broker
baseurl: http://download.opensuse.org/repositories/home:/oojah:/mqtt/CentOS_CentOS-7/
gpgkey: http://download.opensuse.org/repositories/home:/oojah:/mqtt/CentOS_CentOS-7/repodata/repomd.xml.key
- name: Install mttq packages
yum:
name: "{{ item }}"
state: installed
with_items:
- mosquitto
- mosquitto-clients
- name: Create group '{{ mosquitto_group }}'
group:
name: '{{ mosquitto_group }}'
state: present
- name: Create user '{{ mosquitto_user }}'
user:
name: '{{ mosquitto_user }}'
group: '{{ mosquitto_group }}'
system: yes
createhome: no
shell: /sbin/nologin
- name: Copy default configuration
template:
src: "etc/mosquitto/conf.d/default.conf.j2"
dest: "{{ mosquitto_config_dir }}/default.conf"
owner: root
group: root
mode: 0644
notify:
- mosquitto_restart
- name: Copy passwd files
template:
src: "etc/mosquitto/passwd.j2"
dest: "{{ mosquitto_passwd_file }}"
owner: root
group: root
mode: 0600
- name: Hash passwd file
shell: "mosquitto_passwd -U {{ mosquitto_passwd_file }}"
notify:
- mosquitto_restart
- name: Open port for mttq
iptables_raw:
name: allow_mttq_port
state: present
rules: '-A OUTPUT -m state --state NEW -p tcp --dport {{ mosquitto_port }} -j ACCEPT'
- name: Copy systemd unit files
template:
src: "etc/systemd/system/mosquitto.service.j2"
dest: "/etc/systemd/system/mosquitto.service"
owner: root
group: root
mode: 0644
notify:
- mosquitto_restart
- name: Enable systemd service
systemd:
state: started
daemon_reload: yes
enabled: yes
name: mosquitto