thomas_maurice.ansible_role_gitea

Ansible Role Gitea - Install a Gitea Server

Build Status Ansible Role Ansible Role Ansible Quality Score

This role helps you install and manage a Gitea server. You can find the source code and screenshots here.

Gitea is a web app for Git repositories built with Go, resembling GitHub.

Example Playbook Usage

The following example works on Debian 8 and should also work on Ubuntu.

- name: "Install Gitea"
  hosts: all
  vars:
    gitea_user: "gitea"
    gitea_home: "/var/lib/gitea"
    # Limit users to 30 repositories
    gitea_user_repo_limit: 30
    # Disable public CDN for frontend assets
    gitea_offline_mode: true

    # URL rendering options
    gitea_http_domain: git.yourdomain.fr
    gitea_root_url: https://git.yourdomain.fr

    # Assuming we use a reverse proxy for HTTPS,
    # so we bind to localhost:3000 using HTTP
    gitea_protocol: http
    gitea_http_listen: 127.0.0.1
    gitea_http_port: 3000

    # SSH server settings
    gitea_ssh_listen: 0.0.0.0
    gitea_ssh_port: 2222
    gitea_ssh_domain: git.yourdomain.fr
    gitea_start_ssh: true

    gitea_secret_key: 3sp00ky5me
    gitea_disable_gravatar: true
    # Allow user registration
    gitea_disable_registration: false
    gitea_require_signin: true
    gitea_enable_captcha: true

    gitea_show_user_email: false
  roles:
    - gitea

More Detailed Options

General Settings

  • gitea_version_check: Check if the installed version differs from the desired version before downloading.
  • gitea_user: UNIX user for Gitea.
  • gitea_group: UNIX group for Gitea.
  • gitea_home: Base working directory.
  • gitea_dl_url: URL to download the Gitea binary.
  • gitea_systemd_cap_net_bind_service: Allows binding to privileged ports.

Appearance Options

  • gitea_app_name: Name displayed for the application.
  • gitea_show_user_email: Show email addresses? (true/false).
  • gitea_disable_gravatar: Disable Gravatar for privacy? (true/false).
  • gitea_offline_mode: Disable CDNs for assets? (true/false).
  • gitea_disable_registration: Disable user registration? (true/false).
  • gitea_only_allow_external_registration: Force registration through third-party services? (true/false).
  • gitea_show_registration_button: Show registration button? (true/false).
  • gitea_require_signin: Require sign-in to see repositories? (true/false).
  • gitea_enable_captcha: Enable captchas? (true/false).
  • gitea_themes: List of enabled themes.
  • gitea_theme_default: Default theme.

Security Settings

  • gitea_secret_key: Secret key for cookies.
  • gitea_internal_token: Internal API token.
  • gitea_disable_git_hooks: Disable interface for adding git hooks? Defaults to true (true/false).

Limits

  • gitea_user_repo_limit: Maximum number of repositories per user (-1 for unlimited).

HTTP Settings

  • gitea_http_domain: HTTP domain for clone URLs.
  • gitea_root_url: Root URL for web app access.
  • gitea_protocol: Listening protocol (http/https).
  • gitea_http_listen: Bind address.
  • gitea_http_port: Bind port.
  • gitea_disable_http_git: Disable Git over HTTP? (true/false).

SSH Settings

  • gitea_ssh_listen: Bind address for SSH server.
  • gitea_ssh_domain: SSH domain for clone URLs.
  • gitea_start_ssh: Start a built-in SSH server? (true/false).
  • gitea_ssh_port: Bind port for SSH.

Database Settings

  • gitea_db_type: Database type (mysql, postgres, sqlite3).
  • gitea_db_host: Database host string.
  • gitea_db_name: Database name.
  • gitea_db_user: Database username.
  • gitea_db_password: Database password.
  • gitea_db_ssl: Use SSL? (postgres only).
  • gitea_db_path: Database path for sqlite3.

Mailer Settings

  • gitea_mailer_enabled: Enable the mailer? Default: false.
  • gitea_mailer_skip_verify: Skip SMTP certificate verification? (true/false).
  • gitea_mailer_tls_enabled: Enable TLS for SMTP? (true/false).
  • gitea_mailer_host: SMTP server address.
  • gitea_mailer_user: SMTP user.
  • gitea_mailer_password: SMTP password.
  • gitea_mailer_from: Sender email address.
  • gitea_enable_notify_mail: Send notifications to repository watchers? Default: false.

Fail2Ban Settings

Deploys a Fail2Ban configuration if enabled.

  • gitea_fail2ban_enabled: Enable Fail2Ban configuration? (true/false).

OAuth2 Settings

  • gitea_oauth2_enabled: Enable OAuth2 provider? (true/false).
  • gitea_oauth2_jwt_secret: OAuth2 JWT secret.

GIT LFS Settings

Enable Git Large File Storage (LFS):

  • gitea_lfs_enabled: Enable GIT LFS? (true/false).
  • gitea_lfs_secret: JWT secret for remote LFS usage.

Backup on Upgrade

  • gitea_backup_on_upgrade: Option to create a backup during updates. Default: false.
  • gitea_backup_location: Backup storage location. Default: {{ gitea_home }}/backups/.

Contributing

Feel free to create a pull request. If you have questions, you can reach me on Twitter @thomas_maurice.

I'm happy to resolve any issues or review your contributions.

Testing

For testing, use Molecule. First, install the dependencies. It's recommended to use a virtual environment.

pip install pew # Install pew to manage virtual environments.
pew new ansible # Create a new virtual environment.
pip install -r requirements-travis.txt # Install required packages.
molecule test # Run the tests.

Note: Docker must be installed.

Known Limitations

Currently, testing validates that the playbook runs successfully and checks for linting. Since it runs in Docker, we cannot verify if the service is launched by systemd.

License

Copyright 2019-present Thomas Maurice

Redistribution and use in source and binary forms, with or without modification, are permitted as long as the following conditions are met:

1. Source code redistributions must retain the copyright notice and this list of conditions.
2. Binary redistributions must reproduce the copyright notice and this disclaimer in the documentation.
3. The names of the copyright holder and contributors may not be used to endorse or promote derived products without written permission.

THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTIES. THE COPYRIGHT HOLDER OR CONTRIBUTORS ARE NOT LIABLE FOR ANY DAMAGES ARISING FROM THE USE OF THIS SOFTWARE.
Installa
ansible-galaxy install thomas_maurice.ansible_role_gitea
Licenza
bsd-3-clause
Download
82.6k
Proprietario
Lead Site Reliability Engineer