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

Commit

Permalink
Merge pull request #1001 from stephenrlouie/common_vars
Browse files Browse the repository at this point in the history
refactor common
  • Loading branch information
ingvagabund committed Jun 29, 2016
2 parents 5942cde + 7febc3e commit 57d6d6f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 28 deletions.
7 changes: 7 additions & 0 deletions ansible/roles/common/defaults/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,10 @@ bin_dir: /usr/bin
# The directory used by Ansible to temporarily store
# files on Ansible managed systems.
ansible_temp_dir: /tmp/.ansible/files

#Some default values that may get modified in etc/tasks/main.yml
is_atomic: false
is_coreos: false
has_rpm: false
has_firewalld: false
has_iptables: false
28 changes: 4 additions & 24 deletions ansible/roles/common/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,20 @@
---
- name: Determine if Atomic
stat: path=/run/ostree-booted
register: s
register: os_tree_check
changed_when: false
always_run: yes

- name: Init the is_atomic fact
set_fact:
is_atomic: false

- name: Set the is_atomic fact
set_fact:
is_atomic: true
when: s.stat.exists
when: os_tree_check.stat.exists

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

- name: Init the is_coreos fact
set_fact:
is_coreos: false

- name: Set the is_coreos fact
set_fact:
is_coreos: true
Expand All @@ -41,26 +33,14 @@

- name: Determine if has rpm
stat: path=/usr/bin/rpm
register: s
register: rpm_check
changed_when: false
always_run: yes

- name: Init the has_rpm fact
set_fact:
has_rpm: false

- name: Set the has_rpm fact
set_fact:
has_rpm: true
when: s.stat.exists

- name: Init the has_firewalld fact
set_fact:
has_firewalld: false

- name: Init the has_iptables fact
set_fact:
has_iptables: false
when: rpm_check.stat.exists

# collect information about what packages are installed
- include: rpm.yml
Expand Down
8 changes: 4 additions & 4 deletions ansible/roles/common/tasks/rpm.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
---
- name: RPM | Determine if firewalld installed
command: "rpm -q firewalld"
register: s
register: firewalld_check
changed_when: false
failed_when: false
always_run: yes

- name: Set the has_firewalld fact
set_fact:
has_firewalld: true
when: s.rc == 0
when: firewalld_check.rc == 0

- name: Determine if iptables-services installed
command: "rpm -q iptables-services"
register: s
register: iptables_check
changed_when: false
failed_when: false
always_run: yes

- name: Set the has_iptables fact
set_fact:
has_iptables: true
when: s.rc == 0
when: iptables_check.rc == 0

0 comments on commit 57d6d6f

Please sign in to comment.