summaryrefslogtreecommitdiffstats
path: root/ansible/roles
diff options
context:
space:
mode:
authorMichal Ptacek <m.ptacek@partner.samsung.com>2019-03-04 14:52:04 +0000
committerGerrit Code Review <gerrit@onap.org>2019-03-04 14:52:04 +0000
commit69ef231fec01c705f81c9ddae5240090d5710a44 (patch)
tree843d8ce61effd2b9c06020fa27a3be6909bdca24 /ansible/roles
parent1fa643c880dc4e59c1a8fe2c0e3350a7ba44ea00 (diff)
parent8bd90d9023e43ae59effb75caef2a68cc00abe3a (diff)
Merge "Use 'package_facts' module in firewall role"
Diffstat (limited to 'ansible/roles')
-rw-r--r--ansible/roles/firewall/defaults/main.yml6
-rw-r--r--ansible/roles/firewall/tasks/firewall-disable.yml14
-rw-r--r--ansible/roles/firewall/tasks/main.yml2
3 files changed, 13 insertions, 9 deletions
diff --git a/ansible/roles/firewall/defaults/main.yml b/ansible/roles/firewall/defaults/main.yml
new file mode 100644
index 00000000..7cc9ae96
--- /dev/null
+++ b/ansible/roles/firewall/defaults/main.yml
@@ -0,0 +1,6 @@
+---
+firewall:
+ state: disable
+ package_name:
+ RedHat: 'firewalld'
+ Debian: 'ufw'
diff --git a/ansible/roles/firewall/tasks/firewall-disable.yml b/ansible/roles/firewall/tasks/firewall-disable.yml
index 9a8a2c10..f406d943 100644
--- a/ansible/roles/firewall/tasks/firewall-disable.yml
+++ b/ansible/roles/firewall/tasks/firewall-disable.yml
@@ -1,16 +1,14 @@
---
-- name: Check if firewalld is installed
- yum:
- list: firewalld
- disablerepo: "*"
- register: firewalld_check
+- name: Get installed packages list
+ package_facts:
+ manager: "auto"
-- name: Stop and disable firewalld if exists
+- name: Stop and disable default OS firewall if exists
service:
- name: firewalld
+ name: "{{ firewall.package_name[ansible_facts.os_family] }}"
state: stopped
enabled: no
- when: firewalld_check.results|selectattr('yumstate', 'match', 'installed')|list|length != 0
+ when: firewall.package_name[ansible_facts.os_family] in ansible_facts.packages
- name: Flush iptables
iptables:
diff --git a/ansible/roles/firewall/tasks/main.yml b/ansible/roles/firewall/tasks/main.yml
index f7bb7c74..29ea1958 100644
--- a/ansible/roles/firewall/tasks/main.yml
+++ b/ansible/roles/firewall/tasks/main.yml
@@ -1,2 +1,2 @@
---
-- include_tasks: "firewall-{{ state }}.yml"
+- include_tasks: "firewall-{{ firewall.state }}.yml"