Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gitea [lightweight self-hosted Git service] #1242

Merged
merged 58 commits into from
Mar 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
12e8f29
Start creating Gitea role
veeara282 Oct 18, 2018
a7e4b04
Use a less random port number
veeara282 Oct 18, 2018
a66d4ed
Add Apache config file (might need more tweaks)
veeara282 Oct 18, 2018
e351a1c
Add play for downloading Gitea binary
veeara282 Oct 18, 2018
fc7ff3b
Add plays to verify Gitea binary
veeara282 Oct 18, 2018
a6d4990
Move everything to /library/gitea, create more variables
veeara282 Oct 18, 2018
3ad8fac
Create Gitea user
veeara282 Oct 18, 2018
0e8e1c4
Add variable for subdirectories
veeara282 Oct 18, 2018
2fb142e
Create Gitea subdirectories with owner and group
veeara282 Oct 18, 2018
522d4d5
Create symlink
veeara282 Oct 18, 2018
23dfa8b
Set permissions, create /etc/gitea
veeara282 Oct 18, 2018
2c1339f
Add pre-install tag
veeara282 Oct 18, 2018
447b33f
Add app.ini template and configuration plays
veeara282 Oct 18, 2018
8e4dc59
Fail if we detect unknown architecture
veeara282 Oct 18, 2018
4dbd984
Update roles/gitea/tasks/install.yml
holta Oct 26, 2018
6f6bad7
Update roles/gitea/tasks/install.yml
holta Oct 26, 2018
eaf59b0
Update Gitea readme
veeara282 Feb 27, 2019
733f381
Move GPG key to main.yml
veeara282 Feb 27, 2019
9b8af6b
Uncomment MySQL
veeara282 Feb 28, 2019
110688f
Remove commented out code; add configuration instructions
veeara282 Mar 2, 2019
dbd4a61
fix quoting issue
veeara282 Mar 2, 2019
3510bc0
Create gitea group
veeara282 Mar 2, 2019
9a0ada7
Add to default_vars and local_vars_*
veeara282 Mar 2, 2019
96940be
Merge branch 'master' into gitea
Mar 2, 2019
9558b42
fix with_items loop
veeara282 Mar 4, 2019
26399a4
Set HTTP_PORT
veeara282 Mar 4, 2019
7169072
Don't abort if GPG verification fails
veeara282 Mar 5, 2019
a089778
Need to create root directory before user
veeara282 Mar 5, 2019
4ad50b1
Revert "Need to create root directory before user"
veeara282 Mar 5, 2019
5d5fea4
Use correct home directory
veeara282 Mar 5, 2019
d30cc24
Grant write permissions for group gitea
veeara282 Mar 6, 2019
86cd88d
Add clarifying comment about /etc/gitea write permissions
veeara282 Mar 6, 2019
a1fd1fe
1.6 -> 1.7.3
veeara282 Mar 6, 2019
6bb853c
Comment out problematic app.ini values
veeara282 Mar 6, 2019
f64a5bc
Only verify with GPG when requested by user
veeara282 Mar 6, 2019
d3d47fc
Separate home directory with comment
veeara282 Mar 7, 2019
3bab4f2
Use SQLite
veeara282 Mar 7, 2019
195c783
Set RUN_USER and APP_NAME
veeara282 Mar 7, 2019
e253438
Shut down Gitea before reinstalling
veeara282 Mar 7, 2019
5f6f208
Set offline mode to true
veeara282 Mar 7, 2019
d5af5e2
Use box as domain, put gitea_url (default: /gitea) in ROOT_URL
veeara282 Mar 7, 2019
1076827
Revert "Use box as domain, put gitea_url (default: /gitea) in ROOT_URL"
veeara282 Mar 7, 2019
69f8963
ignore errors on pre-install step
veeara282 Mar 7, 2019
59c67dd
Only rewrite URLs in Gitea (not HTTPD)
veeara282 Mar 7, 2019
dec10f2
Move display name to Ansible config
veeara282 Mar 7, 2019
e45d73c
Parameterize database, repositories, LFS, and log locations
veeara282 Mar 7, 2019
3038187
Redirect /gitea -> /gitea/
veeara282 Mar 7, 2019
c4aa784
Skip install screen on first run; configure this in Ansible
veeara282 Mar 7, 2019
a8c24dd
use regex to redirect
veeara282 Mar 7, 2019
b896341
TOML requires Boolean values to be lowercase
veeara282 Mar 8, 2019
2824851
Update roles/gitea/README.rst
holta Mar 8, 2019
d86c985
Update roles/gitea/tasks/install.yml
holta Mar 8, 2019
eea7bea
Update vars/local_vars_medium.yml
holta Mar 8, 2019
73d945e
Apply suggestions from code review
holta Mar 8, 2019
8b447b8
Apply more suggestions from code review
veeara282 Mar 8, 2019
caf87a4
Merge branch 'gitea' of github.com:aidan-fitz/iiab into gitea
veeara282 Mar 8, 2019
ffa2ecb
Don't care about previous state per Ansible convention
veeara282 Mar 8, 2019
31dea06
Add description
veeara282 Mar 8, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions roles/6-generic-apps/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@
when: ejabberd_install
tags: ejabberd

- name: GITEA
include_role:
name: gitea
when: gitea_install
tags: gitea

- name: LOKOLE
include_role:
name: lokole
Expand Down
24 changes: 24 additions & 0 deletions roles/gitea/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
=============
Gitea README
=============

This Ansible role installs Gitea - a self-hosted Git service written in Go.

Using It
--------

Gitea should be accessible at http://box/gitea

Configuration
-------------

Gitea has been configured to work with MySQL; it can also be used with SQLite or
Postgres. If you want to use it with a different database, change the
``DB_TYPE`` property in ``app.ini`` and change the line ``After=mysqld.service``
in ``gitea.service`` to one of the following:

* SQLite: comment it out.
* Postgres: ``After=postgresql.service``

Further information about configuring Gitea can be found at the
`documentation <https://docs.gitea.io/en-us/>`.
60 changes: 60 additions & 0 deletions roles/gitea/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
#gitea_install: True
#gitea_enabled: True

veeara282 marked this conversation as resolved.
Show resolved Hide resolved
# All above are set in: github.com/iiab/iiab/blob/master/vars/default_vars.yml
# If nec, change them by editing /etc/iiab/local_vars.yml prior to installing!

# Using @coolaj86's script as a template
# https://git.coolaj86.com/coolaj86/gitea-installer.sh

# Information needed to install Gitea
gitea_version: "1.7.3"
iset_suffixes:
i386: "386"
x86_64: "amd64"
armv6l: "arm-6"
armv7l: "arm-7"

gitea_iset_suffix: "{{ iset_suffixes[ansible_architecture] | default('unknown') }}"

gitea_download_url: "https://dl.gitea.io/gitea/{{ gitea_version }}/gitea-{{ gitea_version }}-linux-{{ gitea_iset_suffix }}"
gitea_integrity_url: "{{ gitea_download_url }}.asc"

gitea_root_directory: "/library/gitea"
gitea_subdirectories:
- bin
- custom
- data
- indexers
- public
- log
gitea_install_path: "{{ gitea_root_directory }}/bin/gitea-{{ gitea_version }}"
gitea_checksum_path: "{{ gitea_root_directory }}/bin/gitea-{{ gitea_version }}.asc"

gitea_link_path: "{{ gitea_root_directory }}/gitea"

# Information needed to verify Gitea
gitea_gpg_key: 7C9E68152594688862D62AF62D9AE806EC1592E2

# Information needed to run Gitea
gitea_user: gitea
gitea_home: "/home/{{ gitea_user }}" # SSH credentials stored here
gitea_run_directory: "{{ gitea_root_directory }}"

gitea_url: /gitea
gitea_full_url: "http://{{ iiab_hostname }}.{{ iiab_domain }}{{ gitea_url }}"

gitea_port: 61734 # leet for GITEA

# Data locations
gitea_db_path: "{{ gitea_root_directory }}/data/gitea.db"
gitea_repo_root: "{{ gitea_root_directory }}/data/repositories"
gitea_lfs_root: "{{ gitea_root_directory }}/data/lfs"

# Log file location
gitea_log_root: "{{ gitea_root_directory }}/log"

# Extra configuration
gitea_display_name: Internet-in-a-Box Gitea
skip_install_screen: true
190 changes: 190 additions & 0 deletions roles/gitea/tasks/install.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
# Prepare to install Gitea: create user and directory structure

- name: Shut down existing Gitea instance (if we're reinstalling)
systemd:
name: gitea
state: stopped
tags:
- pre-install
ignore_errors: yes

- name: Ensure group gitea exists
group:
name: gitea
state: present
tags:
- pre-install

- name: Create user gitea
user:
name: gitea
comment: Gitea daemon account
groups: gitea
home: "{{ gitea_home }}"
tags:
- pre-install

- name: Create Gitea directory structure
file:
path: "{{ gitea_root_directory }}/{{ item }}"
state: directory
owner: gitea
group: gitea
with_items: "{{ gitea_subdirectories }}"
tags:
- pre-install

- name: Make directories data, indexers, and log writable
file:
path: "{{ gitea_root_directory }}/{{ item }}"
mode: 0750
with_items:
- data
- indexers
- log
tags:
- pre-install

# Download, verify, and link Gitea binary

- 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
get_url:
url: "{{ gitea_download_url }}"
dest: "{{ gitea_install_path }}"
mode: 0775
tags:
- install
when: internet_available

- name: Download Gitea GPG signature
get_url:
url: "{{ gitea_integrity_url }}"
dest: "{{ gitea_checksum_path }}"
tags:
- never
- verify
when: internet_available

- name: Verify Gitea binary with GPG signature
shell: |
gpg --keyserver pgp.mit.edu --recv {{ gitea_gpg_key }}
gpg --verify {{ gitea_checksum_path }} {{ gitea_install_path }}
tags:
- never
- verify
ignore_errors: yes

- name: Link Gitea
file:
src: "{{ gitea_install_path }}"
dest: "{{ gitea_link_path }}"
owner: gitea
group: gitea
state: link
tags:
- install

# 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: Create Gitea config directory
file:
path: /etc/gitea
state: directory
owner: root
group: gitea
mode: 0770
tags:
- config

- name: Create app.ini
template:
src: app.ini.j2
dest: /etc/gitea/app.ini
owner: root
group: gitea
mode: 0664
tags:
- config

# Create systemd service

- name: Create 'gitea' service
template:
src: gitea.service.j2
dest: "/etc/systemd/system/gitea.service"
tags:
- systemd

- name: Enable 'gitea' service
systemd:
daemon_reload: yes
name: gitea
enabled: yes
state: restarted
when: gitea_enabled

- name: Disable 'gitea' service
systemd:
name: gitea
enabled: no
state: stopped
when: not gitea_enabled

# Configure HTTPD

- name: Copy gitea httpd conf file
template:
src: gitea.conf.j2
dest: "/etc/{{ apache_config_dir }}/gitea.conf"

- name: Enable httpd conf file (debuntu)
file:
src: /etc/{{ apache_config_dir }}/gitea.conf
dest: /etc/apache2/sites-enabled/gitea.conf
state: link
when: gitea_enabled and is_debuntu

- name: Remove httpd conf file (OS's other than debuntu)
file:
path: /etc/apache2/sites-enabled/gitea.conf
state: absent
when: not gitea_enabled and is_debuntu

- name: >-
Restart Apache ({{ apache_service }}) to {% if gitea_enabled %}enable{%
else %}disable{% endif %} http://box/gitea
service:
name: "{{ apache_service }}"
state: restarted

# Add Gitea to registry

- name: Add 'gitea' to list of services at {{ iiab_ini_file }}
ini_file:
dest: "{{ iiab_ini_file }}"
section: gitea
option: "{{ item.option }}"
value: "{{ item.value }}"
with_items:
- option: name
value: gitea
- option: description
value: '"Gitea: Git with a cup of tea"'
- option: gitea_run_directory
value: "{{ gitea_run_directory }}"
- option: gitea_url
value: "{{ gitea_url }}"
- option: gitea_full_url
value: "{{ gitea_full_url }}"
- option: gitea_enabled
value: "{{ gitea_enabled }}"
3 changes: 3 additions & 0 deletions roles/gitea/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- name: Install Gitea {{ gitea_version }} if gitea_install
include_tasks: install.yml
when: gitea_install