From a7eb04a15290b580860d0ac5bf27aef097246ff6 Mon Sep 17 00:00:00 2001 From: Alan Orth Date: Wed, 25 Apr 2018 18:00:56 +0300 Subject: [PATCH] Import OS-specific vars from task in common role We stopped being able to do dynamic includes from the playbooks around Ansible 2.4.0.0 if I recall correctly. Instead we can create a task to include the variables and make it always run by using the special tag. For now the Debian and Ubuntu vars files are the same, but I will keep them separate so that it is more flexible in the future. --- roles/common/tasks/main.yml | 3 +++ vars/Ubuntu.yml | 10 ++++++++++ web.yml | 1 - 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 vars/Ubuntu.yml diff --git a/roles/common/tasks/main.yml b/roles/common/tasks/main.yml index 280627f..1ae21ab 100644 --- a/roles/common/tasks/main.yml +++ b/roles/common/tasks/main.yml @@ -1,4 +1,7 @@ --- +- name: Import OS-specific variables + include_vars: "vars/{{ ansible_distribution }}.yml" + tags: always - name: Configure network time import_tasks: ntp.yml diff --git a/vars/Ubuntu.yml b/vars/Ubuntu.yml new file mode 100644 index 0000000..a6921c1 --- /dev/null +++ b/vars/Ubuntu.yml @@ -0,0 +1,10 @@ +--- + +# sshd service name is `ssh` on Debian/Ubuntu, but it's +# `sshd` on CentOS +sshd_service_name: ssh + +# provisioning user vars +provisioning_user: { name: 'provisioning', home: '/home/provisioning' } + +# vim: set ts=2 sw=2: diff --git a/web.yml b/web.yml index f7c5455..45d7c58 100644 --- a/web.yml +++ b/web.yml @@ -13,6 +13,5 @@ - munin vars_files: - vars/ipsets.yml - - vars/Debian.yml # vim: set sw=2 ts=2: