No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

letsencrypt.yml 2.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. - name: Download LetsEncrypt release
  2. git: repo=https://github.com/letsencrypt/letsencrypt
  3. dest=/root/letsencrypt
  4. version=master
  5. - name: Create directory for LetsEncrypt configuration and certificates
  6. file: state=directory path=/etc/letsencrypt group=root owner=root
  7. - name: Configure LetsEncrypt
  8. template:
  9. src=etc_letsencrypt_cli.conf.j2
  10. dest=/etc/letsencrypt/cli.conf
  11. owner=root
  12. group=root
  13. - name: Install LetsEncrypt package dependencies
  14. command: /root/letsencrypt/letsencrypt-auto --help
  15. - name: Install crontab entry for LetsEncrypt
  16. copy:
  17. src=etc_cron-monthly_letsencrypt-renew
  18. dest=/etc/cron.monthly/letsencrypt-renew
  19. owner=root
  20. group=root
  21. mode=755
  22. - name: Create live directory for LetsEncrypt cron job
  23. file: state=directory path=/etc/letsencrypt/live group=root owner=root
  24. - name: Stop Apache
  25. service: name=apache2 state=stopped
  26. - name: Get an SSL certificate for {{ domain }} from Let's Encrypt
  27. script: gencert {{ domain }}
  28. args:
  29. creates: /etc/letsencrypt/live/{{ domain }}/privkey.pem
  30. when: ansible_ssh_user != "vagrant"
  31. - name: Modify permissions to allow ssl-cert group access
  32. file: path=/etc/letsencrypt/archive owner=root group=ssl-cert mode=750
  33. ### Several steps to install a self-signed wildcard key to support offline testing
  34. - name: Create live directory for testing keys
  35. file: dest=/etc/letsencrypt/live/{{ domain }} state=directory
  36. owner=root group=root mode=755
  37. when: ansible_ssh_user == "vagrant"
  38. - name: Copy SSL wildcard private key for testing
  39. copy: src=wildcard_private.key
  40. dest=/etc/letsencrypt/live/{{ domain }}/privkey.pem
  41. owner=root group=ssl-cert mode=640
  42. when: ansible_ssh_user == "vagrant"
  43. - name: Copy SSL public certificate into place for testing
  44. copy: src=wildcard_public_cert.crt
  45. dest=/etc/letsencrypt/live/{{ domain }}/cert.pem
  46. group=root owner=root mode=644
  47. register: certificate
  48. notify: restart apache
  49. when: ansible_ssh_user == "vagrant"
  50. - name: Copy SSL CA combined certificate into place for testing
  51. copy: src=wildcard_ca.pem
  52. dest=/etc/letsencrypt/live/{{ domain }}/chain.pem
  53. group=root owner=root mode=644
  54. register: ca_certificate
  55. notify: restart apache
  56. when: ansible_ssh_user == "vagrant"
  57. - name: Create a combined SSL cert for testing
  58. shell: cat /etc/letsencrypt/live/{{ domain }}/cert.pem
  59. /etc/letsencrypt/live/{{ domain }}/chain.pem >
  60. /etc/letsencrypt/live/{{ domain }}/fullchain.pem
  61. when: private_key.changed or certificate.changed or ca_certificate.changed
  62. when: ansible_ssh_user == "vagrant"
  63. - name: Set permissions on combined SSL public cert
  64. file: name=/etc/letsencrypt/live/{{ domain }}/fullchain.pem mode=644
  65. notify: restart apache
  66. when: ansible_ssh_user == "vagrant"
  67. ### Back to normal
  68. - name: Start Apache
  69. service: name=apache2 state=started