Adds test for systemd

This commit is contained in:
Nikolaos Kakouros 2019-05-12 18:29:59 +02:00
parent d446865f13
commit 9b02af1064
4 changed files with 16 additions and 1 deletions

View File

@ -10,6 +10,8 @@ env:
- MOLECULE_DISTRO: centos6 - MOLECULE_DISTRO: centos6
MOLECULE_PLAYBOOK: playbook-source-install.yml MOLECULE_PLAYBOOK: playbook-source-install.yml
- MOLECULE_DISTRO: ubuntu1804 - MOLECULE_DISTRO: ubuntu1804
- MOLECULE_DISTRO: ubuntu1604
CERTBOT_AUTO_RENEW_SYSTEMD: true
- MOLECULE_DISTRO: ubuntu1604 - MOLECULE_DISTRO: ubuntu1604
- MOLECULE_DISTRO: ubuntu1404 - MOLECULE_DISTRO: ubuntu1404
MOLECULE_PLAYBOOK: playbook-source-install.yml MOLECULE_PLAYBOOK: playbook-source-install.yml

View File

@ -5,6 +5,7 @@
vars: vars:
certbot_auto_renew_user: root certbot_auto_renew_user: root
certbot_auto_renew_systemd: "{{ lookup('env', 'CERTBOT_AUTO_RENEW_SYSTEMD') }}"
pre_tasks: pre_tasks:
- name: Update apt cache. - name: Update apt cache.

View File

@ -1,13 +1,25 @@
--- ---
- name: Get absolute path of certbot executable
command: "which {{ certbot_script }}"
register: certbot_script_absolute
changed_when: false
- name: Create certbot-renew service - name: Create certbot-renew service
template: template:
src: certbot-renew.service.j2 src: certbot-renew.service.j2
dest: /etc/systemd/system/certbot-renew.service dest: /etc/systemd/system/certbot-renew.service
notify: certbot restart renew timer notify: certbot restart renew timer
vars:
certbot_script_path: "{{ certbot_script_absolute.stdout }}"
- name: Create certbot-renew timer - name: Create certbot-renew timer
template: template:
src: certbot-renew.timer.j2 src: certbot-renew.timer.j2
dest: /etc/systemd/system/certbot-renew.timer dest: /etc/systemd/system/certbot-renew.timer
notify: certbot restart renew timer notify: certbot restart renew timer
- name: Start certbot-renew timer
systemd:
name: certbot-renew.timer
state: started

View File

@ -4,6 +4,6 @@ Description=Let's Encrypt renewal service
[Service] [Service]
User={{ certbot_auto_renew_user }} User={{ certbot_auto_renew_user }}
Type=oneshot Type=oneshot
ExecStart={{ certbot_script }} renew --quiet --agree-tos ExecStart={{ certbot_script_path }} renew {{ certbot_auto_renew_options }}
ExecStartPost=/bin/systemctl reload {{ certbot_web_service }}.service ExecStartPost=/bin/systemctl reload {{ certbot_web_service }}.service