main.yml 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. ---
  2. - include: clamav.yml
  3. - include: eventsource.yml
  4. #- include: gitolite.yml
  5. - include: milter.yml
  6. - include: postgres.yml
  7. - name: Install helpful development packages
  8. dnf:
  9. name:
  10. - git
  11. - ngrep
  12. - nmap-ncat
  13. - python3-rpdb
  14. - tmux
  15. - tree
  16. - vim-enhanced
  17. - python3-pip
  18. - httpd
  19. state: present
  20. - name: Install Pagure development packages
  21. dnf:
  22. name:
  23. - python3-alembic
  24. - python3-arrow
  25. - python3-binaryornot
  26. - python3-bleach
  27. - python3-blinker
  28. - python3-celery
  29. - python3-chardet
  30. - python3-cryptography
  31. - python3-docutils
  32. - python3-email-validator
  33. - python3-eventlet
  34. - python3-fedora-flask
  35. - python3-flask
  36. - python3-flask-oidc
  37. - python3-flask-wtf
  38. - python3-jinja2
  39. - python3-markdown
  40. - python3-munch
  41. - python3-mock
  42. - python3-openid-cla
  43. - python3-openid-teams
  44. - python3-pillow
  45. - python3-pip
  46. - python3-psutil
  47. - python3-pygit2
  48. - python3-redis
  49. - python3-sqlalchemy
  50. - python3-straight-plugin
  51. - python3-virtualenvwrapper
  52. - python3-whitenoise
  53. - python3-wtforms
  54. - python3-devel
  55. - python3-devel
  56. - python3-bcrypt
  57. - redhat-rpm-config
  58. state: latest
  59. - name: Create the folder where we'll place the symbolic link for pagure
  60. file:
  61. path: /usr/local/lib/python3.7/site-packages/
  62. state: directory
  63. - name: Create symbolic link for pagure to be in the python path
  64. file:
  65. src: /srv/pagure/pagure
  66. dest: /usr/local/lib/python3.7/site-packages/pagure
  67. state: link
  68. - name: Create symbolic link for python to be py3 by default
  69. file:
  70. src: /usr/bin/python3
  71. dest: /usr/bin/python
  72. state: link
  73. # Add various helpful configuration files
  74. - name: Install a custom bashrc
  75. become_user: "{{ ansible_env.SUDO_USER }}"
  76. copy: src=bashrc dest=/home/{{ ansible_env.SUDO_USER }}/.bashrc
  77. - name: Install the message of the day
  78. copy: src=motd dest=/etc/motd
  79. - name: Remove the motd duplicate
  80. pamd:
  81. name: sshd
  82. type: session
  83. control: optional
  84. module_path: pam_motd.so
  85. state: absent
  86. - name: populate bash history
  87. become_user: "{{ ansible_env.SUDO_USER }}"
  88. copy: src=bash_history dest=/home/{{ ansible_env.SUDO_USER }}/.bash_history
  89. # Configure pagure
  90. - name: Create the git user and group
  91. command: useradd --create-home --home-dir=/srv/git/ git
  92. creates=/srv/git/
  93. - name: create the /attachments folder
  94. file: state=directory
  95. path=/srv/attachments
  96. owner=git group=git mode=0775
  97. - name: Adjust owner of /srv/git
  98. file: name=/srv/git state=directory recurse=yes owner=git group=git
  99. - name: create all the directories used by pagure
  100. file: state=directory
  101. path={{ item }}
  102. owner=git group=git mode=0775
  103. with_items:
  104. - /srv/git/repositories/
  105. - /srv/git/repositories/forks
  106. - /srv/git/repositories/docs
  107. - /srv/git/repositories/tickets
  108. - /srv/git/repositories/requests
  109. - /srv/git/remotes
  110. - /var/www/releases
  111. - /var/www/archives
  112. - /srv/tmp
  113. - name: create the /etc/pagure folder for the config
  114. file: state=directory
  115. path=/etc/pagure
  116. owner=git group=git mode=0775
  117. # Set things up for the mirroring feature
  118. - name: create the `paguremirroring` group
  119. group:
  120. name: paguremirroring
  121. state: present
  122. - name: create the `paguremirroring` user
  123. user:
  124. name: paguremirroring
  125. group: paguremirroring
  126. groups: paguremirroring,git
  127. shell: /bin/nologin
  128. home: /srv/mirror
  129. # Configure the web app
  130. - name: Install the pagure configuration
  131. copy:
  132. src: pagure.cfg
  133. dest: /etc/pagure/pagure.cfg
  134. owner: git
  135. group: git
  136. mode: 0644
  137. - name: Add a working copy of alembic.ini
  138. copy:
  139. src: /srv/pagure/files/alembic.ini
  140. dest: /etc/pagure/alembic.ini
  141. owner: git
  142. group: git
  143. mode: 0644
  144. remote_src: True
  145. - name: Configure alembic to use our development database
  146. replace:
  147. dest: /etc/pagure/alembic.ini
  148. regexp: "sqlalchemy.url = sqlite:////var/tmp/pagure_dev.sqlite"
  149. replace: "sqlalchemy.url = sqlite:////srv/git/pagure_dev.sqlite"
  150. - name: Configure alembic to point to the pagure migration folder
  151. replace:
  152. dest: /etc/pagure/alembic.ini
  153. regexp: "script_location = /usr/share/pagure/alembic"
  154. replace: "script_location = /srv/pagure/alembic/"
  155. - name: Create the Pagure database
  156. become_user: git
  157. command: python3 /srv/pagure/createdb.py
  158. environment:
  159. PAGURE_CONFIG: /etc/pagure/pagure.cfg
  160. args:
  161. creates: /srv/git/pagure_dev.sqlite
  162. - name: Stamp the database with its current migration
  163. become_user: git
  164. shell: alembic-3 stamp $(alembic-3 heads | awk '{ print $1 }')
  165. args:
  166. chdir: "/etc/pagure"
  167. - name: Install the Pagure service files for systemd
  168. copy:
  169. src: "{{ item }}"
  170. dest: /etc/systemd/system/{{ item }}
  171. with_items:
  172. - pagure.service
  173. - pagure-docs.service
  174. - pagure_ci.service
  175. - pagure_ev.service
  176. - pagure_webhook.service
  177. - pagure_worker.service
  178. - pagure_authorized_keys_worker.service
  179. - name: let paguremirroring read the pagure config
  180. command: /usr/bin/setfacl -m user:paguremirroring:rx /etc/pagure/pagure.cfg
  181. - name: Add default facl so apache can read git repos
  182. acl: default=yes etype=user entity=apache permissions="rx" name=/srv/git state=present
  183. register: acl_updates
  184. - name: Manually fix current default ACLs since Ansible doesnt know recursive acls
  185. when: acl_updates.changed
  186. command: /usr/bin/setfacl -Rdm user:apache:rx /srv/git
  187. - name: Manually fix current ACLs since Ansible doesnt know recursive acls
  188. when: acl_updates.changed
  189. command: /usr/bin/setfacl -Rm user:apache:rx /srv/git
  190. - name: Turn off SELinux, this dev box is doing too many unwdily things
  191. command: setenforce 0
  192. - name: Turn off SELinux accross reboot
  193. replace:
  194. dest: /etc/selinux/config
  195. regexp: "SELINUX=enforcing"
  196. replace: "SELINUX=permissive"
  197. - name: Enable and start the all services needed
  198. systemd:
  199. daemon_reload: yes
  200. name: "{{ item }}"
  201. enabled: True
  202. state: started
  203. with_items:
  204. - httpd
  205. - redis
  206. - pagure
  207. - pagure-docs
  208. - pagure_ci
  209. - pagure_ev
  210. - pagure_webhook
  211. - pagure_worker
  212. - pagure_authorized_keys_worker