Skip to content
This repository was archived by the owner on Apr 17, 2019. It is now read-only.

Commit 57d6d6f

Browse files
authored
Merge pull request #1001 from stephenrlouie/common_vars
refactor common
2 parents 5942cde + 7febc3e commit 57d6d6f

File tree

3 files changed

+15
-28
lines changed

3 files changed

+15
-28
lines changed

ansible/roles/common/defaults/main.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,10 @@ bin_dir: /usr/bin
66
# The directory used by Ansible to temporarily store
77
# files on Ansible managed systems.
88
ansible_temp_dir: /tmp/.ansible/files
9+
10+
#Some default values that may get modified in etc/tasks/main.yml
11+
is_atomic: false
12+
is_coreos: false
13+
has_rpm: false
14+
has_firewalld: false
15+
has_iptables: false

ansible/roles/common/tasks/main.yml

+4-24
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,20 @@
11
---
22
- name: Determine if Atomic
33
stat: path=/run/ostree-booted
4-
register: s
4+
register: os_tree_check
55
changed_when: false
66
always_run: yes
77

8-
- name: Init the is_atomic fact
9-
set_fact:
10-
is_atomic: false
11-
128
- name: Set the is_atomic fact
139
set_fact:
1410
is_atomic: true
15-
when: s.stat.exists
11+
when: os_tree_check.stat.exists
1612

1713
- name: Determine if CoreOS
1814
raw: "grep '^NAME=' /etc/os-release | sed s'/NAME=//'"
1915
register: distro
2016
always_run: yes
2117

22-
- name: Init the is_coreos fact
23-
set_fact:
24-
is_coreos: false
25-
2618
- name: Set the is_coreos fact
2719
set_fact:
2820
is_coreos: true
@@ -41,26 +33,14 @@
4133

4234
- name: Determine if has rpm
4335
stat: path=/usr/bin/rpm
44-
register: s
36+
register: rpm_check
4537
changed_when: false
4638
always_run: yes
4739

48-
- name: Init the has_rpm fact
49-
set_fact:
50-
has_rpm: false
51-
5240
- name: Set the has_rpm fact
5341
set_fact:
5442
has_rpm: true
55-
when: s.stat.exists
56-
57-
- name: Init the has_firewalld fact
58-
set_fact:
59-
has_firewalld: false
60-
61-
- name: Init the has_iptables fact
62-
set_fact:
63-
has_iptables: false
43+
when: rpm_check.stat.exists
6444

6545
# collect information about what packages are installed
6646
- include: rpm.yml

ansible/roles/common/tasks/rpm.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
---
22
- name: RPM | Determine if firewalld installed
33
command: "rpm -q firewalld"
4-
register: s
4+
register: firewalld_check
55
changed_when: false
66
failed_when: false
77
always_run: yes
88

99
- name: Set the has_firewalld fact
1010
set_fact:
1111
has_firewalld: true
12-
when: s.rc == 0
12+
when: firewalld_check.rc == 0
1313

1414
- name: Determine if iptables-services installed
1515
command: "rpm -q iptables-services"
16-
register: s
16+
register: iptables_check
1717
changed_when: false
1818
failed_when: false
1919
always_run: yes
2020

2121
- name: Set the has_iptables fact
2222
set_fact:
2323
has_iptables: true
24-
when: s.rc == 0
24+
when: iptables_check.rc == 0

0 commit comments

Comments
 (0)