gogs.yml 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. - name: create group
  2. become: yes
  3. group:
  4. name: "{{ gogs_group }}"
  5. system: yes
  6. state: present
  7. - name: create user
  8. become: yes
  9. user:
  10. name: "{{ gogs_user }}"
  11. home: "{{ gogs_home }}"
  12. group: "{{ gogs_group }}"
  13. system: yes
  14. createhome: yes
  15. state: present
  16. - name: Ensure gogs ssh dir exists
  17. file:
  18. dest: "{{ gogs_home }}/.ssh"
  19. state: directory
  20. mode: 0700
  21. owner: "{{ gogs_user }}"
  22. group: "{{ gogs_group }}"
  23. - name: Ensure gogs ssh key is up to date
  24. copy:
  25. content: "{{ wiki_git_private_key }}"
  26. dest: "{{ gogs_home }}/.ssh/id_rsa"
  27. mode: 0600
  28. owner: "{{ gogs_user }}"
  29. group: "{{ gogs_group }}"
  30. - name: gogs prereqs
  31. become: yes
  32. apt: name={{item}} state=present update_cache=yes cache_valid_time=86400
  33. with_items:
  34. - openssh-server
  35. - git
  36. - name: download gogs binary package
  37. get_url:
  38. url: "{{ gogs_package_url }}"
  39. dest: "{{ gogs_archive }}"
  40. mode: 0644
  41. - name: create gogs repo dir if necessary
  42. become: yes
  43. file:
  44. dest: "{{ gogs_repo_dir }}"
  45. owner: "{{ gogs_user }}"
  46. group: "{{ gogs_group }}"
  47. mode: 0755
  48. state: directory
  49. - name: create gogs db dir if necessary
  50. become: yes
  51. file:
  52. dest: "{{ gogs_sqlite_dir }}"
  53. owner: "{{ gogs_user }}"
  54. group: "{{ gogs_group }}"
  55. mode: 0755
  56. state: directory
  57. - name: unarchive install package
  58. become: yes
  59. unarchive:
  60. src: "{{ gogs_archive }}"
  61. dest: "{{ gogs_home }}"
  62. owner: "{{ gogs_user }}"
  63. group: "{{ gogs_group }}"
  64. copy: no
  65. - name: create gogs custom conf dir
  66. become: yes
  67. file:
  68. dest: "{{ gogs_home }}/gogs/custom/conf"
  69. owner: "{{ gogs_user }}"
  70. group: "{{ gogs_group }}"
  71. mode: 0755
  72. state: directory
  73. - name: Ensure gogs config is up to date
  74. become: yes
  75. template:
  76. src: app.ini.j2
  77. dest: "{{ gogs_config_file }}"
  78. owner: '{{ gogs_user }}'
  79. group: '{{ gogs_group }}'
  80. mode: 0640
  81. notify:
  82. - Restart gogs
  83. - name: Ensure gogs systemd unit is up to date
  84. register: gogssystend
  85. become: yes
  86. template:
  87. src: gogs.service.j2
  88. dest: /etc/systemd/system/gogs.service
  89. - name: Reload systemd
  90. become: yes
  91. when: gogssystend|changed
  92. shell: systemctl daemon-reload
  93. notify:
  94. - Restart gogs
  95. - name: Ensure gogs service is started and enabled
  96. become: yes
  97. service:
  98. name: gogs
  99. state: started
  100. enabled: yes