Add become support to run the role without root

This commit is contained in:
alexppg 2018-10-30 11:20:59 +01:00
parent 1ce5d87ca0
commit 2d4846d79d
2 changed files with 5 additions and 0 deletions

View File

@ -1,10 +1,12 @@
---
- name: Check if certificate already exists.
become: true
stat:
path: /etc/letsencrypt/live/{{ cert_item.domains | first | replace('*.', '') }}/cert.pem
register: letsencrypt_cert
- name: Stop services to allow certbot to generate a cert.
become: true
service:
name: "{{ item }}"
state: stopped
@ -12,10 +14,12 @@
with_items: "{{ certbot_create_standalone_stop_services }}"
- name: Generate new certificate if one doesn't exist.
become: true
shell: "{{ certbot_create_command }}"
when: not letsencrypt_cert.stat.exists
- name: Start services after cert has been generated.
become: true
service:
name: "{{ item }}"
state: started

View File

@ -17,6 +17,7 @@
mode: 0755
- name: Install plugins
become: true
pip:
name: "file://{{ my_certbot_dir}}/certbot-{{ item }}/"
state: present