main.yml 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. ---
  2. - name: Dependencies installed
  3. # We install xmlsec and cairocffi using pkg because python-Levenshtein is tricky to install on FreeBSD
  4. community.general.pkgng:
  5. name: git,py38-pip,fish,direnv,jpeg-turbo,tiff,webp,lcms2,freetype2,syncthing,yarn-node14,cairo,pango,gmake,libxml2,libxslt,postgresql12-client,py38-xmlsec,py38-cairocffi,py38-sqlite3,bash
  6. state: latest
  7. - name: Root shell is fish
  8. ansible.builtin.user: name=root shell=/usr/local/bin/fish
  9. - name: Tmux config installed
  10. copy:
  11. src: tmux.conf
  12. dest: /root/.tmux.conf
  13. mode: 0644
  14. - name: Github SSH key installed
  15. template:
  16. src: sshkey.j2
  17. dest: /root/.ssh/id_ed25519
  18. mode: 0400
  19. - name: Nginx key file installed
  20. copy:
  21. src: key.pem
  22. dest: /usr/local/etc/nginx/key.pem
  23. owner: root
  24. mode: 0644
  25. notify: Nginx restarted
  26. - name: Nginx cert file installed
  27. copy:
  28. src: cert.pem
  29. dest: /usr/local/etc/nginx/cert.pem
  30. owner: root
  31. mode: 0644
  32. notify: Nginx restarted
  33. - name: Nginx site file installed
  34. template:
  35. src: nginx-site.conf.j2
  36. dest: /usr/local/etc/nginx/sites/fifteen5.conf
  37. mode: 0644
  38. notify: Nginx restarted
  39. - name: Nginx location file installed
  40. copy:
  41. src: nginx-location.conf
  42. dest: /usr/local/etc/nginx/locations/fifteen5.conf
  43. mode: 0644
  44. notify: Nginx restarted
  45. - name: Source folder exists
  46. file:
  47. path: /usr/local/src
  48. mode: 0755
  49. state: directory
  50. - name: Create python bin link for yarn
  51. file:
  52. src: /usr/local/bin/python3.8
  53. dest: /usr/bin/python
  54. owner: root
  55. state: link
  56. - name: 15Five source deployed
  57. git:
  58. repo: "git@github.com:15five/fifteen5.git"
  59. dest: /usr/local/src/fifteen5
  60. accept_hostkey: yes
  61. update: yes
  62. ignore_errors: true
  63. tags:
  64. - deploy
  65. - name: Syncthing ignore file installed
  66. copy:
  67. src: stignore
  68. dest: /usr/local/src/fifteen5/.stignore
  69. mode: 0775
  70. - name: Syncthing running as root
  71. shell:
  72. cmd: 'sed -i -e ''/^: ${syncthing_user/s/"syncthing"/"root"/'' /usr/local/etc/rc.d/syncthing'
  73. warn: false
  74. notify: Syncthing restarted
  75. - name: Environment file installed
  76. template:
  77. src: envrc.j2
  78. dest: /usr/local/src/fifteen5/.envrc
  79. mode: 0600
  80. tags:
  81. - deploy
  82. - name: Allow environment file
  83. shell:
  84. cmd: direnv allow
  85. chdir: /usr/local/src/fifteen5
  86. tags:
  87. - deploy
  88. - name: 15Five requirements up to date
  89. pip:
  90. requirements: /usr/local/src/fifteen5/requirements/test.pip
  91. executable: pip
  92. tags:
  93. - deploy
  94. - name: 15Five personal reqs up to date
  95. pip:
  96. name:
  97. - asciitree
  98. - colorlog
  99. - logging_tree
  100. - django-pdb
  101. - pgcli
  102. - ipython
  103. - git+git://github.com/sureapp/sqlformatter
  104. - python-json-logger
  105. executable: pip
  106. tags:
  107. - deploy
  108. - name: 15Five migrations up to date
  109. command: bash -lc "direnv exec /usr/local/src/fifteen5 /usr/local/bin/python3.8 /usr/local/src/fifteen5/manage.py migrate"
  110. tags:
  111. - deploy
  112. - name: 15Five BE supervisor file installed
  113. copy:
  114. src: fifteen5-supervisor.conf
  115. dest: /usr/local/etc/supervisor/conf.d/daphne.conf
  116. owner: root
  117. mode: 0644
  118. notify: Supervisor restarted
  119. - name: 15Five FE supervisor file installed
  120. copy:
  121. src: fifteen5-yarn-supervisor.conf
  122. dest: /usr/local/etc/supervisor/conf.d/yarn.conf
  123. owner: root
  124. mode: 0644
  125. notify: Supervisor restarted
  126. - name: 15Five celery supervisor file installed
  127. copy:
  128. src: celery-supervisor.conf
  129. dest: /usr/local/etc/supervisor/conf.d/celery.conf
  130. owner: root
  131. mode: 0644
  132. notify: Supervisor restarted
  133. - name: 15Five frontend files generated and copied
  134. command: bash -lc "direnv exec /usr/local/src/fifteen5 /usr/local/bin/yarn && direnv exec /usr/local/src/fifteen5 /usr/local/bin/yarn build && direnv exec /usr/local/src/fifteen5 /usr/local/bin/python3.8 manage.py collectstatic --no-input"
  135. args:
  136. chdir: "/usr/local/src/fifteen5"
  137. tags:
  138. - deploy
  139. - never
  140. - name: 15Five reset database
  141. command: bash -lc "RESET_DB=True direnv exec /usr/local/src/fifteen5 /usr/local/bin/python3.8 /usr/local/src/fifteen5/manage.py run_local_scripts && direnv exec /usr/local/src/fifteen5 /usr/local/bin/python3.8 /usr/local/src/fifteen5/manage.py clearsessions"
  142. tags:
  143. - db-refresh
  144. - never