main.yml 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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 location file installed
  20. copy:
  21. src: nginx-location.conf
  22. dest: /usr/local/etc/nginx/locations/fifteen5.conf
  23. mode: 0644
  24. notify: Nginx restarted
  25. - name: Source folder exists
  26. file:
  27. path: /usr/local/src
  28. mode: 0755
  29. state: directory
  30. - name: Create python bin link for yarn
  31. file:
  32. src: /usr/local/bin/python3.8
  33. dest: /usr/bin/python
  34. owner: root
  35. state: link
  36. - name: 15Five source deployed
  37. git:
  38. repo: "git@github.com:15five/fifteen5.git"
  39. dest: /usr/local/src/fifteen5
  40. accept_hostkey: yes
  41. update: yes
  42. ignore_errors: true
  43. tags:
  44. - deploy
  45. - name: Syncthing ignore file installed
  46. copy:
  47. src: stignore
  48. dest: /usr/local/src/fifteen5/.stignore
  49. mode: 0775
  50. - name: Syncthing running as root
  51. shell:
  52. cmd: 'sed -i -e ''/^: ${syncthing_user/s/"syncthing"/"root"/'' /usr/local/etc/rc.d/syncthing'
  53. warn: false
  54. notify: Syncthing restarted
  55. - name: Environment file installed
  56. template:
  57. src: envrc.j2
  58. dest: /usr/local/src/fifteen5/.envrc
  59. mode: 0600
  60. tags:
  61. - deploy
  62. - name: Allow environment file
  63. shell:
  64. cmd: direnv allow
  65. chdir: /usr/local/src/fifteen5
  66. tags:
  67. - deploy
  68. - name: 15Five requirements up to date
  69. pip:
  70. requirements: /usr/local/src/fifteen5/requirements/test.pip
  71. executable: pip
  72. tags:
  73. - deploy
  74. - name: 15Five personal reqs up to date
  75. pip:
  76. name:
  77. - asciitree
  78. - colorlog
  79. - logging_tree
  80. - django-pdb
  81. - pgcli
  82. - ipython
  83. - git+git://github.com/sureapp/sqlformatter
  84. - python-json-logger
  85. executable: pip
  86. tags:
  87. - deploy
  88. - name: 15Five migrations up to date
  89. command: bash -lc "direnv exec /usr/local/src/fifteen5 /usr/local/bin/python3.8 /usr/local/src/fifteen5/manage.py migrate"
  90. tags:
  91. - deploy
  92. - name: 15Five BE supervisor file installed
  93. copy:
  94. src: fifteen5-supervisor.conf
  95. dest: /usr/local/etc/supervisor/conf.d/daphne.conf
  96. owner: root
  97. mode: 0644
  98. notify: Supervisor restarted
  99. - name: 15Five FE supervisor file installed
  100. copy:
  101. src: fifteen5-yarn-supervisor.conf
  102. dest: /usr/local/etc/supervisor/conf.d/yarn.conf
  103. owner: root
  104. mode: 0644
  105. notify: Supervisor restarted
  106. - name: 15Five celery supervisor file installed
  107. copy:
  108. src: celery-supervisor.conf
  109. dest: /usr/local/etc/supervisor/conf.d/celery.conf
  110. owner: root
  111. mode: 0644
  112. notify: Supervisor restarted
  113. - name: 15Five frontend files generated and copied
  114. command: bash -lc "direnv exec /usr/local/src/fifteen5 /usr/local/bin/yarn"
  115. args:
  116. chdir: "/usr/local/src/fifteen5"
  117. tags:
  118. - deploy
  119. - name: 15Five frontend files generated
  120. command: bash -lc "direnv exec /usr/local/src/fifteen5 /usr/local/bin/python3.8 manage.py collectstatic --noinput && direnv exec /usr/local/src/fifteen5 /usr/local/bin/python3.8 manage.py collectstatic_js_reverse"
  121. args:
  122. chdir: "/usr/local/src/fifteen5"
  123. tags:
  124. - deploy
  125. - name: 15Five reset database
  126. 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"
  127. tags:
  128. - db-refresh
  129. - never