2023-06-10 13:10:47 +00:00
- name : Record (initial) disk space used
shell : df -B1 --output=used / | tail -1
2023-05-27 07:26:04 +00:00
register : df1
2020-02-01 23:20:22 +00:00
# 1. Prepare to install Gitea: create user and directory structure
2018-10-18 17:23:18 +00:00
2019-03-07 02:51:05 +00:00
- name : Shut down existing Gitea instance (if we're reinstalling)
systemd :
name : gitea
state : stopped
2019-03-07 04:07:22 +00:00
ignore_errors : yes
2019-03-07 02:51:05 +00:00
2021-07-27 17:47:26 +00:00
- name : Ensure group 'gitea' exists
2019-03-02 08:07:19 +00:00
group :
name : gitea
state : present
2021-07-27 17:47:26 +00:00
- name : Create user 'gitea'
2018-10-18 16:41:16 +00:00
user :
name : gitea
comment : Gitea daemon account
groups : gitea
2020-02-01 23:20:22 +00:00
home : "{{ gitea_home }}" # /home/gitea
2018-10-18 16:41:16 +00:00
2021-07-06 21:59:07 +00:00
- name : Create {{ gitea_root_directory }} directory structures
2018-10-18 16:35:16 +00:00
file :
2020-02-01 23:20:22 +00:00
path : "{{ gitea_root_directory }}/{{ item }}" # /library/gitea
2018-10-18 16:35:16 +00:00
state : directory
2018-10-18 16:50:17 +00:00
owner : gitea
group : gitea
with_items : "{{ gitea_subdirectories }}"
2018-10-18 16:35:16 +00:00
2021-07-27 17:47:26 +00:00
- name : Make directories data, indexers, and log writable (0750)
2018-10-18 16:57:54 +00:00
file :
2020-02-01 23:20:22 +00:00
path : "{{ gitea_root_directory }}/{{ item }}" # /library/gitea
2020-01-14 01:41:03 +00:00
mode : '0750'
2018-10-18 16:57:54 +00:00
with_items :
- data
- indexers
- log
2020-02-01 23:20:22 +00:00
# 2. Download, verify, and link Gitea binary
2018-10-18 16:57:54 +00:00
2018-10-18 21:10:41 +00:00
- name : Fail if we detect unknown architecture
fail :
msg : "Could not find a binary for the CPU architecture \"{{ ansible_architecture }}\""
when : gitea_iset_suffix == "unknown"
2023-07-16 22:21:42 +00:00
- name : Download Gitea binary {{ gitea_download_url }} to {{ gitea_install_path }} (0775, ~126 MB, SLOW DOWNLOAD CAN TAKE ~15 MIN)
2018-10-18 07:26:39 +00:00
get_url :
url : "{{ gitea_download_url }}"
2023-07-16 22:21:42 +00:00
dest : "{{ gitea_install_path }}" # e.g. /library/gitea/bin/gitea-1.20
2021-07-06 21:59:07 +00:00
mode : 0775
2020-11-27 14:06:20 +00:00
timeout : "{{ download_timeout }}"
2018-10-18 07:26:39 +00:00
2021-07-06 21:59:07 +00:00
- name : Download Gitea GPG signature {{ gitea_integrity_url }} to {{ gitea_checksum_path }}
2018-10-18 07:36:00 +00:00
get_url :
url : "{{ gitea_integrity_url }}"
2018-10-18 16:35:16 +00:00
dest : "{{ gitea_checksum_path }}"
2021-12-26 15:24:31 +00:00
timeout : "{{ download_timeout }}"
2018-10-18 07:36:00 +00:00
2023-07-16 22:38:54 +00:00
- name : Verify Gitea binary with GPG signature ("BAD signature" FALSE ALARMS continue as of 2023-07-16, despite their claims at https://docs.gitea.com/installation/install-from-binary#verify-gpg-signature)
2018-10-18 07:36:00 +00:00
shell : |
2023-07-16 22:21:42 +00:00
gpg --keyserver keys.openpgp.org --recv {{ gitea_gpg_key }}
2018-10-18 16:35:16 +00:00
gpg --verify {{ gitea_checksum_path }} {{ gitea_install_path }}
2019-03-05 00:39:35 +00:00
ignore_errors : yes
2018-10-18 07:36:00 +00:00
2020-01-30 09:00:00 +00:00
- name : Symlink {{ gitea_link_path }} -> {{ gitea_install_path }}
2018-10-18 16:52:51 +00:00
file :
src : "{{ gitea_install_path }}"
2022-04-20 15:30:51 +00:00
path : "{{ gitea_link_path }}" # /library/gitea/gitea
2018-10-18 16:52:51 +00:00
owner : gitea
group : gitea
state : link
2020-02-01 23:20:22 +00:00
# 3. Configure Gitea
2018-10-18 17:23:18 +00:00
2019-03-06 20:46:06 +00:00
# For security reasons, the Gitea developers recommend removing group write
# permissions from /etc/gitea/ and /etc/gitea/app.ini after the first run of
# Gitea. User gitea needs write permissions during the first run but not
# subsequent runs.
2021-07-06 21:59:07 +00:00
- name : mkdir /etc/gitea (0770)
2018-10-18 17:23:18 +00:00
file :
state : directory
2020-01-30 09:00:00 +00:00
path : /etc/gitea
2018-10-18 17:23:18 +00:00
owner : root
group : gitea
2021-07-06 21:59:07 +00:00
mode : 0770
2018-10-18 17:23:18 +00:00
2021-07-06 21:59:07 +00:00
- name : Install /etc/gitea/app.ini from template (0664)
2018-10-18 17:23:18 +00:00
template :
src : app.ini.j2
dest : /etc/gitea/app.ini
owner : root
group : gitea
2021-07-06 21:59:07 +00:00
mode : 0664
2018-10-18 17:23:18 +00:00
2020-02-01 23:20:22 +00:00
2021-07-06 21:59:07 +00:00
# 4. Create systemd service & prepare NGINX for http://box/gitea
2018-10-18 17:23:18 +00:00
2021-07-27 17:47:26 +00:00
- name : "Install from template: /etc/systemd/system/gitea.service (by default 0644)"
2018-10-18 07:26:39 +00:00
template :
2020-05-17 03:50:22 +00:00
src : gitea.service.j2
dest : /etc/systemd/system/gitea.service
2020-01-30 09:00:00 +00:00
2020-02-01 23:20:22 +00:00
# 5. RECORD Gitea AS INSTALLED
2020-01-30 09:00:00 +00:00
2023-06-10 13:10:47 +00:00
- name : Record (final) disk space used
shell : df -B1 --output=used / | tail -1
2023-05-27 07:26:04 +00:00
register : df2
2023-06-10 13:10:47 +00:00
- name : Add 'gitea_disk_usage = {{ df2.stdout|int - df1.stdout|int }}' to {{ iiab_ini_file }}
2023-05-27 07:26:04 +00:00
ini_file :
path : "{{ iiab_ini_file }}" # /etc/iiab/iiab.ini
section : gitea
option : gitea_disk_usage
2023-06-10 13:10:47 +00:00
value : "{{ df2.stdout|int - df1.stdout|int }}"
2023-05-27 07:26:04 +00:00
2020-01-30 09:00:00 +00:00
- name : "Set 'gitea_installed: True'"
set_fact :
gitea_installed : True
2018-10-18 07:26:39 +00:00
2020-01-12 23:15:33 +00:00
- name : "Add 'gitea_installed: True' to {{ iiab_state_file }}"
2019-09-14 22:47:41 +00:00
lineinfile :
2020-02-04 00:54:04 +00:00
path : "{{ iiab_state_file }}" # /etc/iiab/iiab_state.yml
2019-09-14 22:47:41 +00:00
regexp : '^gitea_installed'
2019-10-07 17:11:21 +00:00
line: 'gitea_installed : True '