tasks: name "vars" file by the matching "{{ ansible_distribution }}"

This fixes the role to run on Fedora and CentOS.
This commit is contained in:
Thomas Haller 2017-05-02 11:47:54 +02:00
parent 9ae0bde868
commit 52318732bb
7 changed files with 16 additions and 12 deletions

View file

@ -1,9 +1,3 @@
network_provider: "{{ network_providers[ansible_os_family][ansible_distribution_major_version] }}"
network_provider: "{{ network_provider_default }}"
network:
connections: []
network_providers:
RedHat:
"6": "initscripts"
"7": "nm"

View file

@ -1,10 +1,15 @@
- name: Set version specific variables
include_vars: "{{ ansible_os_family }}-{{ ansible_distribution_major_version }}.yml"
include_vars: "{{ item }}"
with_first_found:
- "{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml"
- "{{ ansible_distribution }}.yml"
- "{{ ansible_os_family }}.yml"
- "default.yml"
- name: Install packages
yum:
name: "{{ network_packages | default([]) }}"
state: present
package:
name: "{{ network_packages | default([]) }}"
state: present
- name: Enable network service
service:

1
vars/CentOS-6.yml Symbolic link
View file

@ -0,0 +1 @@
default-initscripts.yml

View file

@ -1 +0,0 @@
network_service_name: network

1
vars/RedHat-6.yml Symbolic link
View file

@ -0,0 +1 @@
default-initscripts.yml

View file

@ -0,0 +1,2 @@
network_service_name: network
network_provider_default: initscripts

View file

@ -1,3 +1,4 @@
network_service_name: NetworkManager
network_packages:
- NetworkManager
network_provider_default: nm

1
vars/default.yml Symbolic link
View file

@ -0,0 +1 @@
default-nm.yml