12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- - name: Add group name ssl-cert for SSL certificates
- group:
- name: ssl-cert
- state: present
-
- - name: add stretch-backport for Certbot
- apt_repository: repo='deb http://deb.debian.org/debian stretch-backports main' state=present update_cache=yes
- tags:
- - dependencies
- when: ansible_distribution_version == '9'
-
- - name: Install Certbot
- apt:
- name: "certbot"
- state: present
- default_release: stretch-backports
- tags:
- - dependencies
- when: ansible_distribution_version == '9'
-
- - name: Install Certbot
- apt:
- name: "certbot"
- state: present
- tags:
- - dependencies
- when: ansible_distribution_version == '10'
-
- - name: Create directory for LetsEncrypt configuration and certificates
- file: state=directory path=/etc/letsencrypt group=root owner=root
-
- - name: Configure LetsEncrypt
- template:
- src=etc_letsencrypt_cli.conf.j2
- dest=/etc/letsencrypt/cli.conf
- owner=root
- group=root
-
- - name: Create directory for pre-renewal scripts
- file: state=directory path=/etc/letsencrypt/prerenew group=root owner=root
-
- - name: Create directory for post-renewal scripts
- file: state=directory path=/etc/letsencrypt/postrenew group=root owner=root
-
- - name: Create pre-renew hook to stop apache
- copy:
- content: "#!/bin/bash\n\nservice apache2 stop\n"
- dest: /etc/letsencrypt/prerenew/apache
- owner: root
- group: root
- mode: 0755
-
- - name: Create post-renew hook to start apache
- copy:
- content: "#!/bin/bash\n\nservice apache2 start\n"
- dest: /etc/letsencrypt/postrenew/apache
- owner: root
- group: root
- mode: 0755
-
- - name: Install crontab entry for LetsEncrypt
- copy:
- src: etc_cron-daily_letsencrypt-renew
- dest: /etc/cron.daily/letsencrypt-renew
- owner: root
- group: root
- mode: 0755
-
- - name: Create live directory for LetsEncrypt cron job
- file: state=directory path=/etc/letsencrypt/live group=ssl-cert owner=root
-
- - name: Get an SSL certificate for {{ virtual_domains | json_query('[*].name') | join(' ') }} from Let's Encrypt
- script: letsencrypt-gencert {{ virtual_domains | json_query('[*].name') | join(' ') }} creates=/etc/letsencrypt/live/{{ domain }}/privkey.pem
-
- - name: Modify permissions to allow ssl-cert group access to archive
- file: path=/etc/letsencrypt/archive owner=root group=ssl-cert mode=0750 recurse=yes
-
- - name: Modify permissions to allow ssl-cert group access to live
- file: path=/etc/letsencrypt/live owner=root group=ssl-cert mode=0750 recurse=yes
|