2
1
mirror of https://gitea.com/gitea/awesome-gitea synced 2024-11-24 23:12:37 +01:00

add nodiscc.xsrv.gitea ansible role (#97)

Hi,

this PR adds the [xsrv.gitea](https://github.com/nodiscc/xsrv/tree/master/roles/gitea) ansible role, which can be used to deploy Gitea on any Debian-based Linux machine.

The role can be used from the [xsrv](https://xsrv.readthedocs.io/en/latest/) command-line tool/ansible wrapper, or with ansible [command-line](https://docs.ansible.com/ansible/latest/user_guide/command_line_tools.html) tools. Optionally it integrates with [netdata](https://github.com/nodiscc/xsrv/tree/master/roles/monitoring_netdata) for instance health monitoring, [apache](https://github.com/nodiscc/xsrv/tree/master/roles/apache) for reverse proxy and SSL/TLS certificate management, [rsnapshot](https://github.com/nodiscc/xsrv/tree/master/roles/backup) for automatic backups, and [postgresql](https://github.com/nodiscc/xsrv/tree/master/roles/postgresql) as a RDBMS.

Detailed installation/configuration documentation can be found at https://xsrv.readthedocs.io/en/latest/installation.html, but here is the short version using ansible command-line tools and self-signed certificates:

```bash
# create a project directory
$ mkdir -p ~/playbooks/myproject && cd ~/playbooks/myproject
# install ansible in a python virtualenv
$ python3 -m venv .venv
$ source .venv/bin/activate
$ pip3 install ansible
```

Create required files and directories (replace my.CHANGEME.org with the address of the server where gitea will be deployed, and other CHANGEME values with values of your choice)

```yaml
# requirements.yml
collections:
  - name: https://gitlab.com/nodiscc/xsrv.git
    type: git
    version: release # or master to get the latest, development version
```

```yaml
# inventory.yml
all:
  hosts:
    my.CHANGEME.org:
```

```yaml
# playbook.yml
- hosts: my.CHANGEME.org
  roles:
    - nodiscc.xsrv.common # (optional) base server setup/hardening/firewall/bruteforce prevention
    - nodiscc.xsrv.monitoring # (optional) server monitoring, log aggregation
    - nodiscc.xsrv.backup # (optional) automatic backups
    - nodiscc.xsrv.apache
    - nodiscc.xsrv.postgresql
    - nodiscc.xsrv.gitea
```

```yaml
# $ mkdir host_vars/my.CHANGEME.org
# host_vars/my.CHANGEME.org/my.CHANGEME.org.yml
#ansible_ssh_port: 2234 # SSH port, if different from 22
#ansible_host: 1.2.3.4 # SSH server address, if my.CHANGEME.org cannot be resolved from DNS
gitea_fqdn: "git.CHANGEME.org" # domain name of the gitea instance
```

```yaml
# $ ansible-vault edit host_vars/my.CHANGEME.org/my.CHANGEME.org.vault.yml
ansible_become_pass: "CHANGEME" # sudo password
gitea_admin_username: "CHANGEME"
gitea_admin_password: "CHANGEME"
gitea_admin_email: "CHANGEME@CHANGEME.org"
gitea_secret_key: "CHANGEME64"
gitea_internal_token: "CHANGEME160"
gitea_oauth2_jwt_secret: "CHANGEME43"
gitea_lfs_jwt_secret: "CHANGEME43"
```

```bash
# make the role/collection available to the ansible project
$ ansible-galaxy collection install --force -r requirements.yml
# deploy the role
$ ansible-playbook -i inventory.yml playbook.yml
```

See [defaults/main.yml](https://github.com/nodiscc/xsrv/blob/master/roles/gitea/defaults/main.yml) for all available configuration variables.

I use the role to manage multiple environments/instances for a few years without problems and will keep maintaining it in the foreseeable future.

Let me know if you need additional information.

Reviewed-on: https://gitea.com/gitea/awesome-gitea/pulls/97
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: pat-s <pat-s@noreply.gitea.io>
Co-authored-by: nodiscc <nodiscc@noreply.gitea.io>
Co-committed-by: nodiscc <nodiscc@noreply.gitea.io>
This commit is contained in:
nodiscc 2022-12-01 19:49:19 +08:00 committed by Lunny Xiao
parent cecae887a7
commit cbee11c833

@ -141,6 +141,7 @@ A curated list of awesome projects related to Gitea.
* [ansible.gitea](https://github.com/melvin-suter/ansible.gitea) - Gitea Setup with Ansible
* [ansible-role-gitea](https://github.com/thomas-maurice/ansible-role-gitea) - Ansible role to deploy a Gitea instance
* [docker-gitea](https://gitea.com/jwobith/docker-gitea) - Docker Gitea Service
* [nodiscc.xsrv.gitea](https://github.com/nodiscc/xsrv/tree/master/roles/gitea) - Ansible role to install and configure Gitea
## SDK