From 2430dc0f205b42f2e0cc90dbdaef99f34d92f2f3 Mon Sep 17 00:00:00 2001 From: John Downey Date: Sat, 22 Oct 2016 18:14:11 -0500 Subject: [PATCH 01/13] Use letsencrypt quiet flag for renewal The output was going to stderr, which wasn't being redirected. This change utilizes the built in quiet feature for renewal. --- tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/main.yml b/tasks/main.yml index e3258a4..abf0c41 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -85,4 +85,4 @@ - name: Install renewal cron become: yes - cron: name="Let's Encrypt Renewal" day="{{ letsencrypt_renewal_frequency.day }}" hour="{{ letsencrypt_renewal_frequency.hour }}" minute="{{ letsencrypt_renewal_frequency.minute }}" job="{{ letsencrypt_venv }}/bin/letsencrypt renew {{ letsencrypt_renewal_command_args }} > /dev/null" + cron: name="Let's Encrypt Renewal" day="{{ letsencrypt_renewal_frequency.day }}" hour="{{ letsencrypt_renewal_frequency.hour }}" minute="{{ letsencrypt_renewal_frequency.minute }}" job="{{ letsencrypt_venv }}/bin/letsencrypt renew --quiet {{ letsencrypt_renewal_command_args }}" From 72936b4b5666444fb7b0248325d4f805f250ae59 Mon Sep 17 00:00:00 2001 From: Johan Guldmyr Date: Tue, 25 Oct 2016 09:22:37 +0300 Subject: [PATCH 02/13] only apt update_cache if pkg_mgr is apt --- tasks/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/tasks/main.yml b/tasks/main.yml index abf0c41..334d8cc 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,6 +1,7 @@ --- - apt: update_cache=yes cache_valid_time=3600 become: yes + when: ansible_pkg_mgr: "apt" tags: install - name: Install depends From 4abf7a4bf9dbd635113647c6cbfcaafb0cd44ec6 Mon Sep 17 00:00:00 2001 From: Johan Guldmyr Date: Tue, 25 Oct 2016 09:26:05 +0300 Subject: [PATCH 03/13] different depend packages to install for RedHat vs Debian --- tasks/main.yml | 2 +- vars/Debian-7.yml | 13 +++++++++++++ vars/RedHat.yml | 14 ++++++++++++++ vars/Ubuntu-14.yml | 12 ++++++++++++ 4 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 vars/RedHat.yml diff --git a/tasks/main.yml b/tasks/main.yml index 334d8cc..e6bed12 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -7,7 +7,7 @@ - name: Install depends package: name={{ item }} state=present become: yes - with_items: + with_items: "{{ letsencrypt_depends }}" - python - python-dev - python-virtualenv diff --git a/vars/Debian-7.yml b/vars/Debian-7.yml index 480dea6..6b0e4af 100644 --- a/vars/Debian-7.yml +++ b/vars/Debian-7.yml @@ -1,3 +1,16 @@ --- # Debian wheezy virtualenv_package_name: python-virtualenv + +letsencrypt_depends: + - python + - python-dev + - python-virtualenv + - gcc + - dialog + - libaugeas0 + - libssl-dev + - libffi-dev + - ca-certificates + - python-pip + - git diff --git a/vars/RedHat.yml b/vars/RedHat.yml new file mode 100644 index 0000000..4293fa0 --- /dev/null +++ b/vars/RedHat.yml @@ -0,0 +1,14 @@ +--- + +letsencrypt_depends: + - python + - python-devel + - python-virtualenv + - gcc + - dialog + - libaugeas0 + - libssl-dev + - libffi-dev + - ca-certificates + - python-pip + - git diff --git a/vars/Ubuntu-14.yml b/vars/Ubuntu-14.yml index aa00a35..ac0a4a6 100644 --- a/vars/Ubuntu-14.yml +++ b/vars/Ubuntu-14.yml @@ -1,3 +1,15 @@ --- # Ubuntu Trusty virtualenv_package_name: python-virtualenv +letsencrypt_depends: + - python + - python-dev + - python-virtualenv + - gcc + - dialog + - libaugeas0 + - libssl-dev + - libffi-dev + - ca-certificates + - python-pip + - git From 29e325080c548a053ffdfb6f5aba80604ec3d113 Mon Sep 17 00:00:00 2001 From: Johan Guldmyr Date: Tue, 25 Oct 2016 09:28:06 +0300 Subject: [PATCH 04/13] correct conditional syntax --- tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/main.yml b/tasks/main.yml index e6bed12..464623a 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,7 +1,7 @@ --- - apt: update_cache=yes cache_valid_time=3600 become: yes - when: ansible_pkg_mgr: "apt" + when: ansible_pkg_mgr == "apt" tags: install - name: Install depends From bc7abed46a143af1a1a41cbc53142b84a124d2fa Mon Sep 17 00:00:00 2001 From: Johan Guldmyr Date: Tue, 25 Oct 2016 09:29:03 +0300 Subject: [PATCH 05/13] point with_items for depends install to a variable instead --- tasks/main.yml | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index 464623a..5c41d48 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -8,17 +8,6 @@ package: name={{ item }} state=present become: yes with_items: "{{ letsencrypt_depends }}" - - python - - python-dev - - python-virtualenv - - gcc - - dialog - - libaugeas0 - - libssl-dev - - libffi-dev - - ca-certificates - - python-pip - - git tags: install - include_vars: "{{ item }}" From 79e3af9b293e27daea8a0cb66c76a851dcad081d Mon Sep 17 00:00:00 2001 From: Johan Guldmyr Date: Tue, 25 Oct 2016 09:31:29 +0300 Subject: [PATCH 06/13] add letsencrypt_depends variable to vars/default.yml too --- vars/default.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/vars/default.yml b/vars/default.yml index 75ef05f..95bcccb 100644 --- a/vars/default.yml +++ b/vars/default.yml @@ -1,3 +1,15 @@ --- virtualenv_package_name: virtualenv +letsencrypt_depends: + - python + - python-devel + - python-virtualenv + - gcc + - dialog + - libaugeas0 + - libssl-dev + - libffi-dev + - ca-certificates + - python-pip + - git From 8922764e38c03c1257bb967871bbcc6690b20cac Mon Sep 17 00:00:00 2001 From: Johan Guldmyr Date: Tue, 25 Oct 2016 09:35:31 +0300 Subject: [PATCH 07/13] include vars earlier (also for package names) --- tasks/main.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index 5c41d48..25711d1 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -4,12 +4,6 @@ when: ansible_pkg_mgr == "apt" tags: install - - name: Install depends - package: name={{ item }} state=present - become: yes - with_items: "{{ letsencrypt_depends }}" - tags: install - - include_vars: "{{ item }}" with_first_found: - "../vars/{{ ansible_distribution }}-{{ ansible_distribution_major_version | int }}.yml" @@ -19,6 +13,12 @@ when: virtualenv_package_name is not defined tags: install + - name: Install depends + package: name={{ item }} state=present + become: yes + with_items: "{{ letsencrypt_depends }}" + tags: install + - name: Install virtualenv package: name={{ item }} state=present become: yes From ce890261ebd14343b024edd62ad73f3a4ec8efa5 Mon Sep 17 00:00:00 2001 From: Johan Guldmyr Date: Tue, 25 Oct 2016 09:35:41 +0300 Subject: [PATCH 08/13] update packages per OS --- vars/RedHat.yml | 8 +++++--- vars/default.yml | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/vars/RedHat.yml b/vars/RedHat.yml index 4293fa0..21a2c2e 100644 --- a/vars/RedHat.yml +++ b/vars/RedHat.yml @@ -6,9 +6,11 @@ letsencrypt_depends: - python-virtualenv - gcc - dialog - - libaugeas0 - - libssl-dev - - libffi-dev + - augeas-libs + - openssl-devel + - openssl-libs + - libffi + - libffi-devel - ca-certificates - python-pip - git diff --git a/vars/default.yml b/vars/default.yml index 95bcccb..c30056c 100644 --- a/vars/default.yml +++ b/vars/default.yml @@ -3,7 +3,7 @@ virtualenv_package_name: virtualenv letsencrypt_depends: - python - - python-devel + - python-dev - python-virtualenv - gcc - dialog From 92bb476f2c9162ac5ff732fd93e7b2f77006fc71 Mon Sep 17 00:00:00 2001 From: Johan Guldmyr Date: Tue, 25 Oct 2016 09:38:28 +0300 Subject: [PATCH 09/13] add virtualenv package name to red hat vars too --- vars/RedHat.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/vars/RedHat.yml b/vars/RedHat.yml index 21a2c2e..b288f42 100644 --- a/vars/RedHat.yml +++ b/vars/RedHat.yml @@ -14,3 +14,5 @@ letsencrypt_depends: - ca-certificates - python-pip - git + +virtualenv_package_name: "python-virtualenv" From 786e7a0302959f4c78bfe37b294fa6ef937c11cc Mon Sep 17 00:00:00 2001 From: Johan Guldmyr Date: Tue, 25 Oct 2016 09:46:56 +0300 Subject: [PATCH 10/13] add EL7 to meta file - tested with EL7 --- meta/main.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/meta/main.yml b/meta/main.yml index bad7b06..cf277a9 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -14,6 +14,9 @@ galaxy_info: - name: Debian versions: - jessie + - name: EL + versions: + - 7 galaxy_tags: - networking From e8ffa89c0c8314550ce689704c9cbde22ed50144 Mon Sep 17 00:00:00 2001 From: Pasha MESH Date: Tue, 6 Dec 2016 14:41:47 +0300 Subject: [PATCH 11/13] Fix for #45 issue --- tasks/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index 25711d1..52df592 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -16,14 +16,14 @@ - name: Install depends package: name={{ item }} state=present become: yes - with_items: "{{ letsencrypt_depends }}" + with_items: "{{ letsencrypt_depends | default([]) }}" tags: install - name: Install virtualenv package: name={{ item }} state=present become: yes with_items: - - "{{ virtualenv_package_name }}" + - "{{ virtualenv_package_name | default([]) }}" tags: install - name: Install python depends From a8a79a151e54f7a3af4f3939e87b620c481da556 Mon Sep 17 00:00:00 2001 From: Ruben Jongejan Date: Thu, 8 Dec 2016 14:36:13 +0100 Subject: [PATCH 12/13] increased readability with native yaml --- tasks/main.yml | 40 ++++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index 52df592..0ecbfcc 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -22,12 +22,16 @@ - name: Install virtualenv package: name={{ item }} state=present become: yes - with_items: - - "{{ virtualenv_package_name | default([]) }}" + with_items: "{{ virtualenv_package_name | default([]) }}" tags: install - name: Install python depends - pip: virtualenv="{{ letsencrypt_venv }}" virtualenv_site_packages=no name={{ item }} state=latest virtualenv_python=python2 + pip: + virtualenv: "{{ letsencrypt_venv }}" + virtualenv_site_packages: no + name: "{{ item }}" + state: latest + virtualenv_python: python2 become: yes with_items: - setuptools @@ -35,12 +39,19 @@ tags: install - name: More python depends - pip: virtualenv="{{ letsencrypt_venv }}" virtualenv_site_packages=no name=letsencrypt state=latest + pip: + virtualenv: "{{ letsencrypt_venv }}" + virtualenv_site_packages: no + name: letsencrypt + state: latest become: yes tags: install - name: Ensure webroot exists - file: path="{{ letsencrypt_webroot_path }}" state=directory follow=yes + file: + path: "{{ letsencrypt_webroot_path }}" + state: directory + follow: yes become: yes - name: Attempt to get the certificate using the webroot authenticator @@ -58,7 +69,11 @@ creates: "/etc/letsencrypt/live/{{ letsencrypt_cert_domains[0] }}" - name: Fix the renewal file - ini_file: section=renewalparams option={{ item.key }} value={{ item.value }} dest="/etc/letsencrypt/renewal/{{ letsencrypt_cert_domains[0] }}.conf" + ini_file: + section: renewalparams + option: "{{ item.key }}" + value: "{{ item.value }}" + dest: "/etc/letsencrypt/renewal/{{ letsencrypt_cert_domains[0] }}.conf" become: yes with_dict: os_packages_only: False @@ -69,10 +84,19 @@ authenticator: '{{ letsencrypt_authenticator }}' - name: Fix the webroot map in the renewal file - ini_file: section="[webroot_map]" option={{ item }} value={{ letsencrypt_webroot_path }} dest="/etc/letsencrypt/renewal/{{ letsencrypt_cert_domains[0] }}.conf" + ini_file: + section: "[webroot_map]" + option: "{{ item }}" + value: "{{ letsencrypt_webroot_path }}" + dest: "/etc/letsencrypt/renewal/{{ letsencrypt_cert_domains[0] }}.conf" become: yes with_items: "{{ letsencrypt_cert_domains }}" - name: Install renewal cron become: yes - cron: name="Let's Encrypt Renewal" day="{{ letsencrypt_renewal_frequency.day }}" hour="{{ letsencrypt_renewal_frequency.hour }}" minute="{{ letsencrypt_renewal_frequency.minute }}" job="{{ letsencrypt_venv }}/bin/letsencrypt renew --quiet {{ letsencrypt_renewal_command_args }}" + cron: + name: "Let's Encrypt Renewal" + day: "{{ letsencrypt_renewal_frequency.day }}" + hour: "{{ letsencrypt_renewal_frequency.hour }}" + minute: "{{ letsencrypt_renewal_frequency.minute }}" + job: "{{ letsencrypt_venv }}/bin/letsencrypt renew --quiet {{ letsencrypt_renewal_command_args }}" From d61908cdbb95bf2accc578b659f53118024b3625 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Fleschenberg?= Date: Mon, 6 Feb 2017 15:02:06 +0100 Subject: [PATCH 13/13] Tell certbot to run non-interactively --- defaults/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/defaults/main.yml b/defaults/main.yml index 74061c1..0614a22 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -6,7 +6,7 @@ letsencrypt_webroot_path: /var/www letsencrypt_authenticator: webroot letsencrypt_email: "webmaster@{{ ansible_domain }}" - letsencrypt_command: "{{ letsencrypt_venv }}/bin/letsencrypt --agree-tos {% if letsencrypt_rsa_key_size is defined %}--rsa-key-size {{ letsencrypt_rsa_key_size }}{% endif %} --text {% for domain in letsencrypt_cert_domains %}-d {{ domain }} {% endfor %}--email {{ letsencrypt_email }} {% if letsencrypt_server is defined %}--server {{ letsencrypt_server }}{% endif %} --expand" + letsencrypt_command: "{{ letsencrypt_venv }}/bin/letsencrypt -n --agree-tos {% if letsencrypt_rsa_key_size is defined %}--rsa-key-size {{ letsencrypt_rsa_key_size }}{% endif %} --text {% for domain in letsencrypt_cert_domains %}-d {{ domain }} {% endfor %}--email {{ letsencrypt_email }} {% if letsencrypt_server is defined %}--server {{ letsencrypt_server }}{% endif %} --expand" letsencrypt_renewal_frequency: day: "*" hour: 0