12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- - name: Add group name ssl-cert for SSL certificates
- group:
- name: ssl-cert
- state: present
-
- - name: Download LetsEncrypt release
- git: repo=https://github.com/letsencrypt/letsencrypt
- dest=/root/letsencrypt
- version=master
- force=yes
-
- - 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: Install LetsEncrypt package dependencies
- command: /root/letsencrypt/letsencrypt-auto --help
- register: le_deps_result
- changed_when: "'Bootstrapping dependencies' in le_deps_result.stdout"
-
- - 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
|