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