Nenhuma descrição
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

letsencrypt.yml 2.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. command: /root/letsencrypt/letsencrypt-auto certonly -c /etc/letsencrypt/cli.conf --domains {{ domain }},{{ subdomains }}
  28. args:
  29. creates: /etc/letsencrypt/live/{{ domain }}/privkey.pem
  30. when: ansible_ssh_user != "vagrant"
  31. ### Several steps to install a self-signed wildcard key to support offline testing
  32. - name: Create live directory for testing keys
  33. file: dest=/etc/letsencrypt/live/{{ domain }} state=directory
  34. owner=root group=root mode=755
  35. when: ansible_ssh_user == "vagrant"
  36. - name: Copy SSL wildcard private key for testing
  37. copy: src=wildcard_private.key
  38. dest=/etc/letsencrypt/live/{{ domain }}/privkey.pem
  39. owner=root group=ssl-cert mode=640
  40. when: ansible_ssh_user == "vagrant"
  41. - name: Copy SSL public certificate into place for testing
  42. copy: src=wildcard_public_cert.crt
  43. dest=/etc/letsencrypt/live/{{ domain }}/cert.pem
  44. group=root owner=root mode=644
  45. register: certificate
  46. notify: restart apache
  47. when: ansible_ssh_user == "vagrant"
  48. - name: Copy SSL CA combined certificate into place for testing
  49. copy: src=wildcard_ca.pem
  50. dest=/etc/letsencrypt/live/{{ domain }}/chain.pem
  51. group=root owner=root mode=644
  52. register: ca_certificate
  53. notify: restart apache
  54. when: ansible_ssh_user == "vagrant"
  55. - name: Create a combined SSL cert for testing
  56. shell: cat /etc/letsencrypt/live/{{ domain }}/cert.pem
  57. /etc/letsencrypt/live/{{ domain }}/chain.pem >
  58. /etc/letsencrypt/live/{{ domain }}/fullchain.pem
  59. when: private_key.changed or certificate.changed or ca_certificate.changed
  60. when: ansible_ssh_user == "vagrant"
  61. - name: Set permissions on combined SSL public cert
  62. file: name=/etc/letsencrypt/live/{{ domain }}/fullchain.pem mode=644
  63. notify: restart apache
  64. when: ansible_ssh_user == "vagrant"
  65. ### Back to normal
  66. - name: Start Apache
  67. service: name=apache2 state=started