main.yml 4.1 KB

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