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

123 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
2019-03-02 08:07:19 +00:00
- name: Ensure group gitea exists
group:
name: gitea
state: present
2018-10-18 16:41:16 +00:00
- name: Create user gitea
user:
name: gitea
comment: Gitea daemon account
groups: gitea
home: "{{ gitea_home }}" # /home/gitea
2018-10-18 16:41:16 +00:00
2018-10-18 16:57:54 +00:00
- name: Create Gitea directory structure
file:
path: "{{ gitea_root_directory }}/{{ item }}" # /library/gitea
state: directory
owner: gitea
group: gitea
with_items: "{{ gitea_subdirectories }}"
2018-10-18 16:57:54 +00:00
- name: Make directories data, indexers, and log writable
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 }}
get_url:
url: "{{ gitea_download_url }}"
dest: "{{ gitea_install_path }}"
mode: '0775'
when: internet_available
2018-10-18 07:36:00 +00:00
- name: Download Gitea GPG signature
get_url:
url: "{{ gitea_integrity_url }}"
dest: "{{ gitea_checksum_path }}"
when: internet_available
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
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
template:
src: app.ini.j2
dest: /etc/gitea/app.ini
owner: root
group: gitea
mode: '0664'
# 4. Create systemd service & prepare Apache for http://box/gitea
- name: "Install from template: /etc/systemd/system/gitea.service"
template:
src: gitea.service.j2
dest: /etc/systemd/system/gitea.service
- name: "Install from template: /etc/{{ apache_conf_dir }}/gitea.conf"
template:
src: gitea.conf.j2
dest: "/etc/{{ apache_conf_dir }}/gitea.conf" # apache2/sites-available
when: apache_installed is defined
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'