From 35ceee9f1b5ff2e71d6f90db61ef10b0a980e54c Mon Sep 17 00:00:00 2001 From: exploide Date: Thu, 23 Feb 2017 20:00:42 +0100 Subject: [PATCH 01/14] restructured tasks such that subtask files are included this is a preparation for installing certbot from package management additionally, it might be useful when further tasks are added, e.g. for initial certificate retrieval --- tasks/install-from-git.yml | 13 +++++++++++++ tasks/main.yml | 21 ++------------------- tasks/renew-cron.yml | 8 ++++++++ 3 files changed, 23 insertions(+), 19 deletions(-) create mode 100644 tasks/install-from-git.yml create mode 100644 tasks/renew-cron.yml diff --git a/tasks/install-from-git.yml b/tasks/install-from-git.yml new file mode 100644 index 0000000..24a3544 --- /dev/null +++ b/tasks/install-from-git.yml @@ -0,0 +1,13 @@ +--- +- name: Clone Certbot into configured directory. + git: + repo: "{{ certbot_repo }}" + dest: "{{ certbot_dir }}" + version: "{{ certbot_version }}" + update: "{{ certbot_keep_updated }}" + force: yes + +- name: Ensure certbot-auto is executable. + file: + path: "{{ certbot_dir }}/certbot-auto" + mode: 0755 diff --git a/tasks/main.yml b/tasks/main.yml index 5e17fb6..27aab86 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,22 +1,5 @@ --- -- name: Clone Certbot into configured directory. - git: - repo: "{{ certbot_repo }}" - dest: "{{ certbot_dir }}" - version: "{{ certbot_version }}" - update: "{{ certbot_keep_updated }}" - force: yes +- include: install-from-git.yml -- name: Ensure certbot-auto is executable. - file: - path: "{{ certbot_dir }}/certbot-auto" - mode: 0755 - -- name: Add cron job for 'certbot-auto renew' (if configured). - cron: - name: Certbot automatic renewal. - job: "{{ certbot_dir }}/certbot-auto renew --quiet --no-self-upgrade" - minute: "{{ certbot_auto_renew_minute }}" - hour: "{{ certbot_auto_renew_hour }}" - user: "{{ certbot_auto_renew_user }}" +- include: renew-cron.yml when: certbot_auto_renew diff --git a/tasks/renew-cron.yml b/tasks/renew-cron.yml new file mode 100644 index 0000000..62ba3bd --- /dev/null +++ b/tasks/renew-cron.yml @@ -0,0 +1,8 @@ +--- +- name: Add cron job for 'certbot-auto renew' (if configured). + cron: + name: Certbot automatic renewal. + job: "{{ certbot_dir }}/certbot-auto renew --quiet --no-self-upgrade" + minute: "{{ certbot_auto_renew_minute }}" + hour: "{{ certbot_auto_renew_hour }}" + user: "{{ certbot_auto_renew_user }}" From f3a260e94e9d48d269e15b821255244110424a86 Mon Sep 17 00:00:00 2001 From: exploide Date: Fri, 24 Feb 2017 10:10:20 +0100 Subject: [PATCH 02/14] added possibility to install certbot from package management - introduces a variable certbot_from_git - adds install from package tasks - makes a variable called certbot_script available (to handle certbot vs certbot-auto naming) - fixes #18 --- defaults/main.yml | 3 ++- tasks/install-from-git.yml | 6 +++++- tasks/install-from-package.yml | 7 +++++++ tasks/main.yml | 4 ++++ tasks/renew-cron.yml | 4 ++-- 5 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 tasks/install-from-package.yml diff --git a/defaults/main.yml b/defaults/main.yml index 793362c..53be380 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,10 +1,11 @@ --- # Where to get Certbot. +certbot_from_git: no certbot_repo: https://github.com/certbot/certbot.git certbot_version: master certbot_keep_updated: yes -# Where to put Certbot. +# Where to put Certbot when cloning from Git. certbot_dir: /opt/certbot # How to keep Certbot certs up to date. diff --git a/tasks/install-from-git.yml b/tasks/install-from-git.yml index 24a3544..8ff2040 100644 --- a/tasks/install-from-git.yml +++ b/tasks/install-from-git.yml @@ -7,7 +7,11 @@ update: "{{ certbot_keep_updated }}" force: yes +- name: Set Certbot script variable + set_fact: + certbot_script: "{{ certbot_dir }}/certbot-auto" + - name: Ensure certbot-auto is executable. file: - path: "{{ certbot_dir }}/certbot-auto" + path: "{{ certbot_script }}" mode: 0755 diff --git a/tasks/install-from-package.yml b/tasks/install-from-package.yml new file mode 100644 index 0000000..20f4a2f --- /dev/null +++ b/tasks/install-from-package.yml @@ -0,0 +1,7 @@ +--- +- name: Install Certbot + package: name=certbot state=present + +- name: Set Certbot script variable + set_fact: + certbot_script: certbot diff --git a/tasks/main.yml b/tasks/main.yml index 27aab86..0f1ac91 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,5 +1,9 @@ --- +- include: install-from-package.yml + when: not certbot_from_git + - include: install-from-git.yml + when: certbot_from_git - include: renew-cron.yml when: certbot_auto_renew diff --git a/tasks/renew-cron.yml b/tasks/renew-cron.yml index 62ba3bd..7678a7c 100644 --- a/tasks/renew-cron.yml +++ b/tasks/renew-cron.yml @@ -1,8 +1,8 @@ --- -- name: Add cron job for 'certbot-auto renew' (if configured). +- name: Add cron job for certbot renewal (if configured). cron: name: Certbot automatic renewal. - job: "{{ certbot_dir }}/certbot-auto renew --quiet --no-self-upgrade" + job: "{{ certbot_script }} renew --quiet --no-self-upgrade" minute: "{{ certbot_auto_renew_minute }}" hour: "{{ certbot_auto_renew_hour }}" user: "{{ certbot_auto_renew_user }}" From b82eeeed799ecbb34215d43adc9b5fcc50fca453 Mon Sep 17 00:00:00 2001 From: exploide Date: Fri, 24 Feb 2017 10:16:07 +0100 Subject: [PATCH 03/14] adapted README to cover install from package possibility --- README.md | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 101c6f3..bfd0353 100644 --- a/README.md +++ b/README.md @@ -6,26 +6,27 @@ Installs Certbot (for Let's Encrypt) for RHEL/CentOS or Debian/Ubuntu. ## Requirements -Certbot requires Git to be installed. You can install Git using the `geerlingguy.git` role. +Certbot requires Git to be installed if one wants to install Certbot from Git repository instead of package management. You can install Git using the `geerlingguy.git` role. ## Role Variables + certbot_from_git: no certbot_repo: https://github.com/certbot/certbot.git certbot_version: master certbot_keep_updated: yes -Certbot code repository options. This role clones the agent from the configured repo, then makes the `certbot-auto` script executable. +Certbot Git repository options. This role clones the agent from the configured repo, then makes the `certbot-auto` script executable if `certbot_from_git` is `yes`. Otherwise it will be installed from distribution's package management. certbot_dir: /opt/certbot -The directory inside which Certbot will be cloned. +The directory inside which Certbot will be cloned when using Git. certbot_auto_renew: true certbot_auto_renew_user: "{{ ansible_user }}" certbot_auto_renew_hour: 3 certbot_auto_renew_minute: 30 -By default, this role configures a cron job to run under the provided user account at the given hour and minute, every day. The defaults run `certbot-auto renew` via cron every day at 03:30:00 by the user you use in your Ansible playbook. It's preferred that you set a custom user/hour/minute so the renewal is during a low-traffic period and done by a non-root user account. +By default, this role configures a cron job to run under the provided user account at the given hour and minute, every day. The defaults run `certbot renew` (or `certbot-auto renew`) via cron every day at 03:30:00 by the user you use in your Ansible playbook. It's preferred that you set a custom user/hour/minute so the renewal is during a low-traffic period and done by a non-root user account. ## Dependencies @@ -34,20 +35,20 @@ None. ## Example Playbook - hosts: servers - + vars: certbot_auto_renew_user: your_username_here certbot_auto_renew_minute: 20 certbot_auto_renew_hour: 5 - + roles: - geerlingguy.certbot -After installation, you can create certificates using the `certbot-auto` script, which by default is installed inside the configured `certbot_dir`, so by default, `/opt/certbot/certbot-auto`. Here are some example commands to configure certificates with Certbot: +After installation, you can create certificates using the `certbot` (or `certbot-auto`) script, which by default is installed inside the configured `certbot_dir` (when using Git). Here are some example commands to configure certificates with Certbot: # Automatically add certs for all Apache virtualhosts (use with caution!). /opt/certbot/certbot-auto --apache - + # Generate certs, but don't modify Apache configuration (safer). /opt/certbot/certbot-auto --apache certonly From 33724b0a9361e4e75d20eb0e6b3fd4e39eb9d1ad Mon Sep 17 00:00:00 2001 From: exploide Date: Fri, 24 Feb 2017 10:19:01 +0100 Subject: [PATCH 04/14] this role is also compatible with Fedora - mention Fedora in meta - adapt description of role because this role should work on most distributions, not only EL and Debian/Ubuntu --- README.md | 2 +- meta/main.yml | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index bfd0353..ba8cf6a 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![Build Status](https://travis-ci.org/geerlingguy/ansible-role-certbot.svg?branch=master)](https://travis-ci.org/geerlingguy/ansible-role-certbot) -Installs Certbot (for Let's Encrypt) for RHEL/CentOS or Debian/Ubuntu. +Installs and configures Certbot (for Let's Encrypt). ## Requirements diff --git a/meta/main.yml b/meta/main.yml index 2a9422b..ee4dc79 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -3,7 +3,7 @@ dependencies: [] galaxy_info: author: geerlingguy - description: "Certbot (for Let's Encrypt) for RHEL/CentOS and Debian/Ubuntu." + description: "Installs and configures Certbot (for Let's Encrypt)." company: "Midwestern Mac, LLC" license: "license (BSD, MIT)" min_ansible_version: 1.8 @@ -12,12 +12,15 @@ galaxy_info: versions: - 6 - 7 + - name: Fedora + versions: + - all - name: Ubuntu versions: - - all + - all - name: Debian versions: - - all + - all galaxy_tags: - networking - system From afa993333fdb4b0d4023be7ec2dcd6717c657825 Mon Sep 17 00:00:00 2001 From: exploide Date: Sun, 19 Mar 2017 14:38:07 +0100 Subject: [PATCH 05/14] renamed certbot_from_git variable to certbot_install_from_source and fixed some wording --- README.md | 4 ++-- defaults/main.yml | 2 +- tasks/{install-from-git.yml => install-from-source.yml} | 2 +- ...{install-from-package.yml => install-with-package.yml} | 4 ++-- tasks/main.yml | 8 ++++---- 5 files changed, 10 insertions(+), 10 deletions(-) rename tasks/{install-from-git.yml => install-from-source.yml} (91%) rename tasks/{install-from-package.yml => install-with-package.yml} (57%) diff --git a/README.md b/README.md index ba8cf6a..83bc68e 100644 --- a/README.md +++ b/README.md @@ -10,12 +10,12 @@ Certbot requires Git to be installed if one wants to install Certbot from Git re ## Role Variables - certbot_from_git: no + certbot_install_from_source: no certbot_repo: https://github.com/certbot/certbot.git certbot_version: master certbot_keep_updated: yes -Certbot Git repository options. This role clones the agent from the configured repo, then makes the `certbot-auto` script executable if `certbot_from_git` is `yes`. Otherwise it will be installed from distribution's package management. +Certbot Git repository options. This role clones the agent from the configured repo, then makes the `certbot-auto` script executable if `certbot_install_from_source` is `yes`. Otherwise it will be installed from distribution's package management. certbot_dir: /opt/certbot diff --git a/defaults/main.yml b/defaults/main.yml index 53be380..cf4bb2b 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,6 +1,6 @@ --- # Where to get Certbot. -certbot_from_git: no +certbot_install_from_source: no certbot_repo: https://github.com/certbot/certbot.git certbot_version: master certbot_keep_updated: yes diff --git a/tasks/install-from-git.yml b/tasks/install-from-source.yml similarity index 91% rename from tasks/install-from-git.yml rename to tasks/install-from-source.yml index 8ff2040..7d97f9b 100644 --- a/tasks/install-from-git.yml +++ b/tasks/install-from-source.yml @@ -7,7 +7,7 @@ update: "{{ certbot_keep_updated }}" force: yes -- name: Set Certbot script variable +- name: Set Certbot script variable. set_fact: certbot_script: "{{ certbot_dir }}/certbot-auto" diff --git a/tasks/install-from-package.yml b/tasks/install-with-package.yml similarity index 57% rename from tasks/install-from-package.yml rename to tasks/install-with-package.yml index 20f4a2f..0155963 100644 --- a/tasks/install-from-package.yml +++ b/tasks/install-with-package.yml @@ -1,7 +1,7 @@ --- -- name: Install Certbot +- name: Install Certbot. package: name=certbot state=present -- name: Set Certbot script variable +- name: Set Certbot script variable. set_fact: certbot_script: certbot diff --git a/tasks/main.yml b/tasks/main.yml index 0f1ac91..06d5512 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,9 +1,9 @@ --- -- include: install-from-package.yml - when: not certbot_from_git +- include: install-with-package.yml + when: not certbot_install_from_source -- include: install-from-git.yml - when: certbot_from_git +- include: install-from-source.yml + when: certbot_install_from_source - include: renew-cron.yml when: certbot_auto_renew From ef18833af5777bc1153fdee82aa0d2adb4227dec Mon Sep 17 00:00:00 2001 From: exploide Date: Sun, 19 Mar 2017 14:49:28 +0100 Subject: [PATCH 06/14] made README more clear regarding package vs source installation --- README.md | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 83bc68e..277a135 100644 --- a/README.md +++ b/README.md @@ -6,20 +6,11 @@ Installs and configures Certbot (for Let's Encrypt). ## Requirements -Certbot requires Git to be installed if one wants to install Certbot from Git repository instead of package management. You can install Git using the `geerlingguy.git` role. +If one wants to install Certbot from upstream Git repository instead of distribution's package management, this role requires Git to be installed. You can install Git using the `geerlingguy.git` role. ## Role Variables - certbot_install_from_source: no - certbot_repo: https://github.com/certbot/certbot.git - certbot_version: master - certbot_keep_updated: yes - -Certbot Git repository options. This role clones the agent from the configured repo, then makes the `certbot-auto` script executable if `certbot_install_from_source` is `yes`. Otherwise it will be installed from distribution's package management. - - certbot_dir: /opt/certbot - -The directory inside which Certbot will be cloned when using Git. +The variable `certbot_install_from_source` controls whether to install Certbot from Git or package management. The latter is the default, so the variable defaults to `no`. certbot_auto_renew: true certbot_auto_renew_user: "{{ ansible_user }}" @@ -28,6 +19,19 @@ The directory inside which Certbot will be cloned when using Git. By default, this role configures a cron job to run under the provided user account at the given hour and minute, every day. The defaults run `certbot renew` (or `certbot-auto renew`) via cron every day at 03:30:00 by the user you use in your Ansible playbook. It's preferred that you set a custom user/hour/minute so the renewal is during a low-traffic period and done by a non-root user account. +### Variables Relavant for Source Installation from Git + + certbot_install_from_source: yes + certbot_repo: https://github.com/certbot/certbot.git + certbot_version: master + certbot_keep_updated: yes + +Certbot Git repository options. This clones the configured `certbot_repo`, respecting the `certbot_version` setting. If `certbot_keep_updated` is set to `yes`, the repository is updated every time this role runs. + + certbot_dir: /opt/certbot + +The directory inside which Certbot will be cloned. + ## Dependencies None. From 141dd088827aef5d198dee3b1935e7d3c2a072bf Mon Sep 17 00:00:00 2001 From: exploide Date: Sun, 19 Mar 2017 15:51:54 +0100 Subject: [PATCH 07/14] package module requires Ansible >= 2.0 --- meta/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meta/main.yml b/meta/main.yml index ee4dc79..aa00a88 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -6,7 +6,7 @@ galaxy_info: description: "Installs and configures Certbot (for Let's Encrypt)." company: "Midwestern Mac, LLC" license: "license (BSD, MIT)" - min_ansible_version: 1.8 + min_ansible_version: 2.0 platforms: - name: EL versions: From 1f8931618270b86051e6586c1d4db5936285ff0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Sch=C3=B6ldstr=C3=B6m?= Date: Sun, 19 Mar 2017 10:43:53 -0500 Subject: [PATCH 08/14] Fix Centos6 tests by testing source install --- .travis.yml | 11 ++++++++--- tests/test-source-install.yml | 14 ++++++++++++++ tests/test.yml | 1 - 3 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 tests/test-source-install.yml diff --git a/.travis.yml b/.travis.yml index 1ee8c0a..d8206d8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,18 +5,23 @@ env: - distro: centos7 init: /usr/lib/systemd/systemd run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro" + playbook: test.yml - distro: centos6 init: /sbin/init run_opts: "" + playbook: test-source-install.yml - distro: ubuntu1604 init: /lib/systemd/systemd run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro" + playbook: test.yml - distro: ubuntu1404 init: /sbin/init run_opts: "" + playbook: test.yml - distro: ubuntu1204 init: /sbin/init run_opts: "" + playbook: test.yml before_install: # Pull container. @@ -31,14 +36,14 @@ script: - 'docker exec "$(cat ${container_id})" ansible-galaxy install -r /etc/ansible/roles/role_under_test/tests/requirements.yml' # Ansible syntax check. - - 'docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml --syntax-check' + - 'docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/${playbook} --syntax-check' # Test role. - - 'docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml' + - 'docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/${playbook}' # Test role idempotence. - idempotence=$(mktemp) - - docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml | tee -a ${idempotence} + - docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/roles/role_under_test/tests/${playbook} | tee -a ${idempotence} - > tail ${idempotence} | grep -q 'changed=0.*failed=0' diff --git a/tests/test-source-install.yml b/tests/test-source-install.yml new file mode 100644 index 0000000..697df9c --- /dev/null +++ b/tests/test-source-install.yml @@ -0,0 +1,14 @@ +--- +- hosts: all + + vars: + certbot_install_from_source: yes + + pre_tasks: + - name: Install cron (RedHat). + yum: name=cronie state=present + when: ansible_os_family == 'RedHat' + + roles: + - geerlingguy.git + - role_under_test diff --git a/tests/test.yml b/tests/test.yml index cf90f58..217fc45 100644 --- a/tests/test.yml +++ b/tests/test.yml @@ -16,5 +16,4 @@ when: ansible_os_family == 'Debian' roles: - - geerlingguy.git - role_under_test From c82468099b2037888a2785113e6f019fdaebe084 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Sch=C3=B6ldstr=C3=B6m?= Date: Sun, 19 Mar 2017 11:03:45 -0500 Subject: [PATCH 09/14] Run source-install tests for Ubuntu 14.04 as there's no package available --- .travis.yml | 2 +- tests/test-source-install.yml | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d8206d8..e429be2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,7 +17,7 @@ env: - distro: ubuntu1404 init: /sbin/init run_opts: "" - playbook: test.yml + playbook: test-source-install.yml - distro: ubuntu1204 init: /sbin/init run_opts: "" diff --git a/tests/test-source-install.yml b/tests/test-source-install.yml index 697df9c..d2a3d73 100644 --- a/tests/test-source-install.yml +++ b/tests/test-source-install.yml @@ -5,10 +5,19 @@ certbot_install_from_source: yes pre_tasks: + - name: Update apt cache. + apt: update_cache=yes cache_valid_time=600 + when: ansible_os_family == 'Debian' + changed_when: false + - name: Install cron (RedHat). yum: name=cronie state=present when: ansible_os_family == 'RedHat' + - name: Install cron (Debian). + apt: name=cron state=present + when: ansible_os_family == 'Debian' + roles: - geerlingguy.git - role_under_test From 92ef96faff271ea81c2e549b9f21c5bcbba0e8a3 Mon Sep 17 00:00:00 2001 From: exploide Date: Sun, 19 Mar 2017 17:17:08 +0100 Subject: [PATCH 10/14] notes on distributions which do not ship certbot package --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 277a135..e05050e 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,10 @@ By default, this role configures a cron job to run under the provided user accou ### Variables Relavant for Source Installation from Git +Instead of installing Certbot from distribution's package management, installing from Git repository is also an option. This might be useful in several cases, but especially when older LTS distributions don't ship Certbot yet. These include CentOS < 7, Ubuntu < 16.10 and Debian < 8. Debian 8 includes Certbot package when packports repository is enabled. + +In case source installation from Git is intended, the following variables are relevant: + certbot_install_from_source: yes certbot_repo: https://github.com/certbot/certbot.git certbot_version: master From e82a68e331f7ac67140220f477524f6f05d901b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Sch=C3=B6ldstr=C3=B6m?= Date: Sat, 25 Mar 2017 08:59:38 -0500 Subject: [PATCH 11/14] Support Ubuntu 16.04 out of the box --- tasks/install-with-package.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tasks/install-with-package.yml b/tasks/install-with-package.yml index 0155963..bdc1ede 100644 --- a/tasks/install-with-package.yml +++ b/tasks/install-with-package.yml @@ -1,7 +1,17 @@ --- +- 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 state=present + package: "name={{ certbot_package }} state=present" - name: Set Certbot script variable. set_fact: - certbot_script: certbot + certbot_script: "{{ certbot_package }}" From da5a6738d51429f2fdeac8fdcdf3dea3242d6071 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Sch=C3=B6ldstr=C3=B6m?= Date: Sat, 25 Mar 2017 09:06:59 -0500 Subject: [PATCH 12/14] Show playbook right after distro in tests, change ubuntu1204 -> debian8 --- .travis.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index e429be2..8968680 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,25 +3,25 @@ services: docker env: - distro: centos7 + playbook: test.yml init: /usr/lib/systemd/systemd run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro" - playbook: test.yml - distro: centos6 + playbook: test-source-install.yml init: /sbin/init run_opts: "" - playbook: test-source-install.yml - distro: ubuntu1604 + playbook: test.yml init: /lib/systemd/systemd run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro" - playbook: test.yml - distro: ubuntu1404 - init: /sbin/init - run_opts: "" playbook: test-source-install.yml - - distro: ubuntu1204 init: /sbin/init run_opts: "" + - distro: debian8 playbook: test.yml + init: /lib/systemd/systemd + run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro" before_install: # Pull container. From 1ca3e00b46566c54c1c61cd9ab460286e5b1a83a Mon Sep 17 00:00:00 2001 From: exploide Date: Sat, 1 Apr 2017 14:23:08 +0200 Subject: [PATCH 13/14] 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 From 24d40c7b108e5f5cbed2546606cb95d9f5b17731 Mon Sep 17 00:00:00 2001 From: exploide Date: Sat, 1 Apr 2017 14:26:02 +0200 Subject: [PATCH 14/14] use test-source-install for Debian 8 since certbot (and letsencrypt) packages are only available from jessi-backports repo --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 8968680..5715f3e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,7 +19,7 @@ env: init: /sbin/init run_opts: "" - distro: debian8 - playbook: test.yml + playbook: test-source-install.yml init: /lib/systemd/systemd run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"