add task for iptables
This commit is contained in:
parent
eacfcfb454
commit
b90ef48c51
@ -10,5 +10,7 @@ mosquitto_bind_address: "{{ ansible_default_ipv4.address }}"
|
|||||||
mosquitto_persistence_enabled: False
|
mosquitto_persistence_enabled: False
|
||||||
mosquitto_persistence_path: /var/lib/mosquitto/mosquitto.db
|
mosquitto_persistence_path: /var/lib/mosquitto/mosquitto.db
|
||||||
|
|
||||||
|
mosquitto_iptables_enabled: False
|
||||||
|
|
||||||
mosquitto_tls_enabled: False
|
mosquitto_tls_enabled: False
|
||||||
mosquitto_ca_path: /etc/pki/tls/certs/
|
mosquitto_ca_path: /etc/pki/tls/certs/
|
||||||
|
@ -1,62 +1,17 @@
|
|||||||
---
|
---
|
||||||
- name: Copy passwd files
|
- block:
|
||||||
template:
|
- name: Copy passwd file to '{{ mosquitto_passwd_path }}'
|
||||||
src: "etc/mosquitto/passwd.j2"
|
template:
|
||||||
dest: "{{ mosquitto_passwd_file }}"
|
src: "etc/mosquitto/passwd.j2"
|
||||||
owner: root
|
dest: "{{ mosquitto_passwd_path }}"
|
||||||
group: root
|
owner: root
|
||||||
mode: 0600
|
group: root
|
||||||
|
mode: 0600
|
||||||
|
register: __mosquitto_passwd
|
||||||
|
|
||||||
- name: Hash passwd file
|
- name: Hash passwd file
|
||||||
shell: "mosquitto_passwd -U {{ mosquitto_passwd_file }}"
|
shell: "mosquitto_passwd -U {{ mosquitto_passwd_path }}"
|
||||||
notify:
|
notify: __mosquitto_restart
|
||||||
- mosquitto_restart
|
when: __mosquitto_passwd.changed
|
||||||
|
become: True
|
||||||
- name: Copy TLS CA Stack
|
become_user: root
|
||||||
block:
|
|
||||||
- name: Copy tls chained certs
|
|
||||||
copy:
|
|
||||||
content: "{{ mosquitto_ca_content }}"
|
|
||||||
dest: "{{ mosquitto_ca_file }}"
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
mode: 0644
|
|
||||||
notify:
|
|
||||||
- mosquitto_restart
|
|
||||||
|
|
||||||
- name: Copy tls intermediate CA
|
|
||||||
copy:
|
|
||||||
content: "{{ mosquitto_cert_content }}"
|
|
||||||
dest: "{{ mosquitto_cert_file }}"
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
mode: 0644
|
|
||||||
notify:
|
|
||||||
- mosquitto_restart
|
|
||||||
|
|
||||||
- name: Copy tls private key
|
|
||||||
copy:
|
|
||||||
content: "{{ mosquitto_private_key_content }}"
|
|
||||||
dest: "{{ mosquitto_private_key_file }}"
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
mode: 0600
|
|
||||||
notify:
|
|
||||||
- mosquitto_restart
|
|
||||||
when: mosquitto_tls_enabled
|
|
||||||
|
|
||||||
- name: Open port for mttq
|
|
||||||
iptables_raw:
|
|
||||||
name: allow_mttq_port
|
|
||||||
state: present
|
|
||||||
rules: '-A INPUT -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
|
|
||||||
|
@ -26,5 +26,12 @@
|
|||||||
group: root
|
group: root
|
||||||
mode: 0644
|
mode: 0644
|
||||||
notify: __mosquitto_restart
|
notify: __mosquitto_restart
|
||||||
|
|
||||||
|
- name: Open port in iptables
|
||||||
|
iptables_raw:
|
||||||
|
name: allow_mosquitto_port
|
||||||
|
state: present
|
||||||
|
rules: '-A INPUT -m state --state NEW -p tcp --dport {{ mosquitto_port }} -j ACCEPT'
|
||||||
|
when: mosquitto_iptables_enabled
|
||||||
become: True
|
become: True
|
||||||
become_user: root
|
become_user: root
|
||||||
|
Loading…
Reference in New Issue
Block a user