From 1ca3e00b46566c54c1c61cd9ab460286e5b1a83a Mon Sep 17 00:00:00 2001 From: exploide Date: Sat, 1 Apr 2017 14:23:08 +0200 Subject: [PATCH] include distribution specific vars from files --- tasks/include-vars.yml | 8 ++++++++ tasks/install-with-package.yml | 10 ---------- tasks/main.yml | 2 ++ vars/Ubuntu-16.04.yml | 1 + vars/default.yml | 2 ++ 5 files changed, 13 insertions(+), 10 deletions(-) create mode 100644 tasks/include-vars.yml create mode 100644 vars/Ubuntu-16.04.yml create mode 100644 vars/default.yml diff --git a/tasks/include-vars.yml b/tasks/include-vars.yml new file mode 100644 index 0000000..0a70e50 --- /dev/null +++ b/tasks/include-vars.yml @@ -0,0 +1,8 @@ +--- +- name: Load a variable file based on the OS type, or a default if not found. + include_vars: "{{ item }}" + with_first_found: + - "{{ ansible_distribution }}-{{ ansible_distribution_version }}.yml" + - "{{ ansible_distribution }}.yml" + - "{{ ansible_os_family }}.yml" + - "default.yml" diff --git a/tasks/install-with-package.yml b/tasks/install-with-package.yml index bdc1ede..10490ff 100644 --- a/tasks/install-with-package.yml +++ b/tasks/install-with-package.yml @@ -1,14 +1,4 @@ --- -- name: Define certbot_package (Ubuntu 16.04). - set_fact: - certbot_package: letsencrypt - when: ansible_distribution == 'Ubuntu' and ansible_distribution_version == '16.04' - -- name: Define certbot_package. - set_fact: - certbot_package: certbot - when: certbot_package is undefined - - name: Install Certbot. package: "name={{ certbot_package }} state=present" diff --git a/tasks/main.yml b/tasks/main.yml index 06d5512..5324ff9 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,4 +1,6 @@ --- +- include: include-vars.yml + - include: install-with-package.yml when: not certbot_install_from_source diff --git a/vars/Ubuntu-16.04.yml b/vars/Ubuntu-16.04.yml new file mode 100644 index 0000000..90e9138 --- /dev/null +++ b/vars/Ubuntu-16.04.yml @@ -0,0 +1 @@ +certbot_package: letsencrypt diff --git a/vars/default.yml b/vars/default.yml new file mode 100644 index 0000000..d88f2dc --- /dev/null +++ b/vars/default.yml @@ -0,0 +1,2 @@ +--- +certbot_package: certbot