暂无描述
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

gitea.yml 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. - name: Create temporary gitea directory
  2. file: state=directory path=/root/gitea
  3. - name: Download gitea {{ gitea_version }} release
  4. get_url:
  5. url="{{ gitea_release }}"
  6. dest=/root/gitea/gitea-{{ gitea_version }}
  7. - name: Make gitea release download executable
  8. file: path=/root/gitea/gitea-{{ gitea_version }} mode=0775
  9. - name: Create /usr/local/bin
  10. file: state=directory path=/usr/local/bin
  11. - name: Stop old gitea instance
  12. service: name=gitea state=stopped
  13. ignore_errors: True
  14. - name: Copy gitea binary to /usr/local/bin
  15. shell: cp gitea/gitea-{{ gitea_version }} /usr/local/bin/gitea chdir=/root
  16. - name: Add git user
  17. user:
  18. name: git
  19. home: /home/git
  20. create_home: yes
  21. shell: /bin/bash
  22. password_lock: yes
  23. state: present
  24. system: yes
  25. - name: Create gitea data directories
  26. file:
  27. state: directory
  28. path: "/data/{{ item }}"
  29. owner: git
  30. group: git
  31. mode: 0750
  32. with_items:
  33. - gitea
  34. - gitea/custom
  35. - gitea/data
  36. - gitea/log
  37. - gitea/repos
  38. - name: Create gitea config directory
  39. file:
  40. state: directory
  41. path: "/etc/gitea"
  42. owner: git
  43. group: git
  44. mode: 0750
  45. - name: Add gitea config file
  46. template:
  47. src=etc_gitea_app_ini.j2
  48. dest=/etc/gitea/app.ini
  49. owner=git
  50. group=root
  51. mode=0644
  52. - name: Add gitea postgres user
  53. postgresql_user:
  54. login_host=localhost
  55. login_user={{ db_admin_username }}
  56. login_password="{{ db_admin_password }}"
  57. name={{ gitea_db_username }}
  58. password="{{ gitea_db_password }}"
  59. encrypted=yes
  60. state=present
  61. - name: Create gitea database
  62. postgresql_db:
  63. login_host=localhost
  64. login_user={{ db_admin_username }}
  65. login_password="{{ db_admin_password }}"
  66. name={{ gitea_db_database }}
  67. state=present
  68. owner={{ gitea_db_username }}
  69. # Unfortunately, create-user is not idempotent, so this task will fail
  70. # https://github.com/go-gitea/gitea/issues/6307
  71. - name: Create gitea admin user account
  72. become: true
  73. become_user: git
  74. shell: /usr/local/bin/gitea admin create-user --admin --config /etc/gitea/app.ini --name {{ gitea_admin_username }} --password {{ gitea_admin_password }} --email {{ admin_email }}
  75. args:
  76. chdir: /data/gitea
  77. ignore_errors: True
  78. - name: Add fail2ban script for gitea
  79. copy:
  80. src=etc_fail2ban_filter.d_gitea.conf
  81. dest=/etc/fail2ban/filter.d/gitea.conf
  82. owner=root
  83. group=root
  84. - name: Add systemd service to start gitea automatically
  85. copy:
  86. src=etc_systemd_system_gitea.service
  87. dest=/etc/systemd/system/gitea.service
  88. owner=root
  89. group=root
  90. - name: Register new gitea service
  91. systemd: name=gitea daemon_reload=yes enabled=yes
  92. - name: Start new gitea instance
  93. service: name=gitea state=started
  94. - name: Create the Apache gitea sites config files
  95. template:
  96. src=etc_apache2_sites-available_gitea.j2
  97. dest=/etc/apache2/sites-available/gitea_{{ item.name }}.conf
  98. owner=root
  99. group=root
  100. with_items: "{{ virtual_domains }}"
  101. - name: Enable Apache sites (creates new sites-enabled symlinks)
  102. command: a2ensite gitea_{{ item }}.conf creates=/etc/apache2/sites-enabled/gitea_{{ item }}.conf
  103. notify: restart apache
  104. with_items: "{{ virtual_domains | json_query('[*].name') }}"