1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-13 19:52:06 +00:00
iiab/roles/gitea/tasks/install.yml

117 lines
3.1 KiB
YAML
Raw Normal View History

# 1. Prepare to install Gitea: create user and directory structure
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
- name: Ensure group 'gitea' exists
2019-03-02 08:07:19 +00:00
group:
name: gitea
state: present
- name: Create user 'gitea'
2018-10-18 16:41:16 +00:00
user:
name: gitea
comment: Gitea daemon account
groups: gitea
home: "{{ gitea_home }}" # /home/gitea
2018-10-18 16:41:16 +00:00
- name: Create {{ gitea_root_directory }} directory structures
file:
path: "{{ gitea_root_directory }}/{{ item }}" # /library/gitea
state: directory
owner: gitea
group: gitea
with_items: "{{ gitea_subdirectories }}"
- name: Make directories data, indexers, and log writable (0750)
2018-10-18 16:57:54 +00:00
file:
path: "{{ gitea_root_directory }}/{{ item }}" # /library/gitea
mode: '0750'
2018-10-18 16:57:54 +00:00
with_items:
- data
- indexers
- log
# 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"
- name: Download Gitea binary {{ gitea_download_url }} to {{ gitea_install_path }} (0775, ~102 MB)
get_url:
url: "{{ gitea_download_url }}"
dest: "{{ gitea_install_path }}" # e.g. /library/gitea/bin/gitea-1.15
mode: 0775
timeout: "{{ download_timeout }}"
- 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 }}"
dest: "{{ gitea_checksum_path }}"
timeout: "{{ download_timeout }}"
2018-10-18 07:36:00 +00:00
- name: Verify Gitea binary with GPG signature
shell: |
2019-02-27 22:02:55 +00:00
gpg --keyserver pgp.mit.edu --recv {{ gitea_gpg_key }}
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 }}"
2020-01-30 09:00:00 +00:00
path: "{{ gitea_link_path }}"
2018-10-18 16:52:51 +00:00
owner: gitea
group: gitea
state: link
# 3. Configure Gitea
# 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.
- name: mkdir /etc/gitea (0770)
file:
state: directory
2020-01-30 09:00:00 +00:00
path: /etc/gitea
owner: root
group: gitea
mode: 0770
- name: Install /etc/gitea/app.ini from template (0664)
template:
src: app.ini.j2
dest: /etc/gitea/app.ini
owner: root
group: gitea
mode: 0664
# 4. Create systemd service & prepare NGINX for http://box/gitea
- name: "Install from template: /etc/systemd/system/gitea.service (by default 0644)"
template:
src: gitea.service.j2
dest: /etc/systemd/system/gitea.service
2020-01-30 09:00:00 +00:00
# 5. RECORD Gitea AS INSTALLED
2020-01-30 09:00:00 +00:00
- name: "Set 'gitea_installed: True'"
set_fact:
gitea_installed: True
- name: "Add 'gitea_installed: True' to {{ iiab_state_file }}"
2019-09-14 22:47:41 +00:00
lineinfile:
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'