1
0

main.yml 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. ---
  2. - name: Install nginx
  3. become: true
  4. apt:
  5. name: [ nginx, certbot, python3-certbot-nginx ]
  6. state: present
  7. - name: Place temporary nginx config
  8. become: true
  9. template:
  10. src: templates/nginx.j2
  11. dest: /etc/nginx/sites-available/joystreamstats
  12. - name: Link nginx config
  13. become: true
  14. file:
  15. src: /etc/nginx/sites-available/joystreamstats
  16. path: /etc/nginx/sites-enabled/joystreamstats
  17. state: link
  18. - name: Remove default nginx config
  19. become: true
  20. file:
  21. path: /etc/nginx/sites-enabled/default
  22. state: absent
  23. - name: Extract letsencrypt account
  24. become: true
  25. unarchive:
  26. creates: /etc/letsencrypt/account
  27. #remote_src: false
  28. src: templates/letsencrypt.tar.xz
  29. dest: /
  30. owner: root
  31. group: root
  32. mode: '0700'
  33. - name: Run certbot
  34. become: true
  35. shell: certbot certonly --nginx -n -d "{{ inventory_hostname }}.api.joystreamstats.live"
  36. args:
  37. creates: /etc/letsencrypt/live/{{ inventory_hostname }}.api.joystreamstats.live
  38. # https://certbot.eff.org/lets-encrypt/debianbuster-nginx
  39. - name: Place SSL-enabled nginx config
  40. become: true
  41. template:
  42. src: templates/nginx-ssl.j2
  43. dest: /etc/nginx/sites-available/joystreamstats
  44. - name: Reload nginx service
  45. become: true
  46. systemd:
  47. name: nginx
  48. state: reloaded
  49. enabled: true
  50. - name: Update joystream-node service file
  51. become: true
  52. template:
  53. src: templates/joystream-node.service.j2
  54. dest: /etc/systemd/system/joystream-node.service
  55. - name: Update systemd daemon
  56. become: true
  57. shell: systemctl daemon-reload
  58. - name: Restart joystream service
  59. become: true
  60. systemd:
  61. name: joystream-node
  62. state: restarted
  63. enabled: true
  64. - name: Update hostname
  65. become: yes
  66. shell: hostname {{ inventory_hostname }}.api.joystreamstats.live
  67. - name: Overwrite hostname file
  68. become: yes
  69. shell: echo {{ inventory_hostname }}.api.joystreamstats.live > /etc/hostname