main.yml 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. ---
  2. # tasks file for ffdo.gitit
  3. - name: Ensure group for gitit exists
  4. group: name={{gitit_group}}
  5. - name: Ensure user for gitit exists
  6. user:
  7. name: "{{ gitit_user }}"
  8. createhome: no
  9. home: "{{ gitit_data_dir }}"
  10. group: "{{ gitit_group }}"
  11. - name: Ensure gitit ssh dir exists
  12. file:
  13. dest: "{{ gitit_data_dir }}/.ssh"
  14. state: directory
  15. mode: 0700
  16. owner: "{{ gitit_user }}"
  17. group: "{{ gitit_group }}"
  18. - name: Ensure gitit ssh key is up to date
  19. copy:
  20. content: "{{ wiki_git_private_key }}"
  21. dest: "{{ gitit_data_dir }}/.ssh/id_rsa"
  22. mode: 0600
  23. owner: "{{ gitit_user }}"
  24. group: "{{ gitit_group }}"
  25. - name: Ensure gitconfig exists
  26. template:
  27. src: gitconfig.j2
  28. dest: "{{ gitit_data_dir }}/.gitconfig"
  29. owner: "{{ gitit_user }}"
  30. group: "{{ gitit_group }}"
  31. - name: Ensure prerequisites for gitit are instaled
  32. apt: name={{ item }} state=present update_cache=yes cache_valid_time=3600
  33. with_items:
  34. - git
  35. - gitit
  36. - name: Install gitit configuration
  37. template:
  38. src: conf.j2
  39. dest: "{{ gitit_data_dir }}/gitit.conf"
  40. owner: "{{ gitit_user }}"
  41. notify:
  42. - Restart gitit
  43. - name: Ensure static content directories exists
  44. file:
  45. dest: "{{ gitit_data_dir }}/static/{{item}}"
  46. state: directory
  47. owner: "{{ gitit_user }}"
  48. with_items:
  49. - css
  50. - img
  51. - name: Ensure template directory exists
  52. file:
  53. dest: "{{ gitit_data_dir }}/templates"
  54. state: directory
  55. owner: "{{ gitit_user }}"
  56. - name: Ensure custom footer exists
  57. template:
  58. src: footer.st.j2
  59. dest: "{{ gitit_data_dir }}/templates/footer.st"
  60. owner: "{{ gitit_user }}"
  61. - name: Ensure custom css exists
  62. template:
  63. src: custom.css.j2
  64. dest: "{{ gitit_data_dir }}/static/css/custom.css"
  65. owner: "{{ gitit_user }}"
  66. - name: Ensure wikidata directory exists
  67. file:
  68. dest: "{{ gitit_data_dir }}/wikidata"
  69. state: directory
  70. owner: "{{ gitit_user }}"
  71. - name: Clone wiki repo
  72. git:
  73. repo: "{{ gitit_wiki_repo }}"
  74. dest: "{{ gitit_data_dir }}/wikidata"
  75. key_file: "{{ gitit_data_dir }}/.ssh/id_rsa"
  76. accept_hostkey: yes
  77. umask: "002"
  78. - name: Ensure git hooks are in place
  79. copy:
  80. src: "{{ item }}"
  81. dest: "{{ gitit_data_dir }}/wikidata/.git/hooks/{{ item }}"
  82. owner: "{{ gitit_user }}"
  83. mode: 0776
  84. with_items:
  85. - post-commit
  86. - post-update
  87. # TODO restore user data
  88. - name: Let acmetool generate a key and a certificate
  89. become: yes
  90. shell: /usr/bin/acmetool want --batch {{ wiki_domain }}
  91. notify: Restart nginx
  92. - name: Install nginx configs
  93. template:
  94. src: "nginx.j2"
  95. dest: "/etc/nginx/sites-available/wiki"
  96. notify:
  97. - Restart nginx
  98. - name: Activate nginx configurations
  99. file:
  100. src: /etc/nginx/sites-available/wiki
  101. dest: /etc/nginx/sites-enabled/wiki
  102. state: link
  103. notify:
  104. - Restart nginx
  105. - name: Install systemd unit
  106. register: gitit_systemd_unit
  107. template:
  108. src: systemd.j2
  109. dest: /etc/systemd/system/gitit.service
  110. - name: Systemd daemon-reload
  111. when: gitit_systemd_unit|changed
  112. shell: systemctl daemon-reload
  113. - name: Ensure gitit is started and enabled
  114. service: name=gitit state=started enabled=yes