├── .ansible-lint ├── .github ├── FUNDING.yml ├── stale.yml └── workflows │ ├── ci.yml │ └── release.yml ├── .gitignore ├── .yamllint ├── LICENSE ├── README.md ├── defaults └── main.yml ├── handlers └── main.yml ├── meta └── main.yml ├── molecule └── default │ ├── converge.yml │ ├── molecule.yml │ └── requirements.yml ├── tasks ├── gogs-mysql.yml ├── init-setup.yml └── main.yml ├── templates └── gogs.unit.j2 └── vars ├── Debian.yml └── RedHat.yml /.ansible-lint: -------------------------------------------------------------------------------- 1 | skip_list: 2 | - 'yaml' 3 | - 'role-name' 4 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | --- 3 | github: geerlingguy 4 | patreon: geerlingguy 5 | -------------------------------------------------------------------------------- /.github/stale.yml: -------------------------------------------------------------------------------- 1 | # Configuration for probot-stale - https://github.com/probot/stale 2 | 3 | # Number of days of inactivity before an Issue or Pull Request becomes stale 4 | daysUntilStale: 90 5 | 6 | # Number of days of inactivity before an Issue or Pull Request with the stale label is closed. 7 | # Set to false to disable. If disabled, issues still need to be closed manually, but will remain marked as stale. 8 | daysUntilClose: 30 9 | 10 | # Only issues or pull requests with all of these labels are check if stale. Defaults to `[]` (disabled) 11 | onlyLabels: [] 12 | 13 | # Issues or Pull Requests with these labels will never be considered stale. Set to `[]` to disable 14 | exemptLabels: 15 | - pinned 16 | - security 17 | - planned 18 | 19 | # Set to true to ignore issues in a project (defaults to false) 20 | exemptProjects: false 21 | 22 | # Set to true to ignore issues in a milestone (defaults to false) 23 | exemptMilestones: false 24 | 25 | # Set to true to ignore issues with an assignee (defaults to false) 26 | exemptAssignees: false 27 | 28 | # Label to use when marking as stale 29 | staleLabel: stale 30 | 31 | # Limit the number of actions per hour, from 1-30. Default is 30 32 | limitPerRun: 30 33 | 34 | pulls: 35 | markComment: |- 36 | This pull request has been marked 'stale' due to lack of recent activity. If there is no further activity, the PR will be closed in another 30 days. Thank you for your contribution! 37 | 38 | Please read [this blog post](https://www.jeffgeerling.com/blog/2020/enabling-stale-issue-bot-on-my-github-repositories) to see the reasons why I mark pull requests as stale. 39 | 40 | unmarkComment: >- 41 | This pull request is no longer marked for closure. 42 | 43 | closeComment: >- 44 | This pull request has been closed due to inactivity. If you feel this is in error, please reopen the pull request or file a new PR with the relevant details. 45 | 46 | issues: 47 | markComment: |- 48 | This issue has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution! 49 | 50 | Please read [this blog post](https://www.jeffgeerling.com/blog/2020/enabling-stale-issue-bot-on-my-github-repositories) to see the reasons why I mark issues as stale. 51 | 52 | unmarkComment: >- 53 | This issue is no longer marked for closure. 54 | 55 | closeComment: >- 56 | This issue has been closed due to inactivity. If you feel this is in error, please reopen the issue or file a new issue with the relevant details. 57 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: CI 3 | 'on': 4 | pull_request: 5 | push: 6 | branches: 7 | - master 8 | schedule: 9 | - cron: "0 5 * * 2" 10 | 11 | defaults: 12 | run: 13 | working-directory: 'geerlingguy.gogs' 14 | 15 | jobs: 16 | 17 | lint: 18 | name: Lint 19 | runs-on: ubuntu-latest 20 | steps: 21 | - name: Check out the codebase. 22 | uses: actions/checkout@v2 23 | with: 24 | path: 'geerlingguy.gogs' 25 | 26 | - name: Set up Python 3. 27 | uses: actions/setup-python@v2 28 | with: 29 | python-version: '3.x' 30 | 31 | - name: Install test dependencies. 32 | run: pip3 install yamllint 33 | 34 | - name: Lint code. 35 | run: | 36 | yamllint . 37 | 38 | molecule: 39 | name: Molecule 40 | runs-on: ubuntu-latest 41 | strategy: 42 | matrix: 43 | distro: 44 | - centos7 45 | - ubuntu1804 46 | - debian9 47 | 48 | steps: 49 | - name: Check out the codebase. 50 | uses: actions/checkout@v2 51 | with: 52 | path: 'geerlingguy.gogs' 53 | 54 | - name: Set up Python 3. 55 | uses: actions/setup-python@v2 56 | with: 57 | python-version: '3.x' 58 | 59 | - name: Install test dependencies. 60 | run: pip3 install ansible molecule[docker] docker 61 | 62 | - name: Run Molecule tests. 63 | run: molecule test 64 | env: 65 | PY_COLORS: '1' 66 | ANSIBLE_FORCE_COLOR: '1' 67 | MOLECULE_DISTRO: ${{ matrix.distro }} 68 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # This workflow requires a GALAXY_API_KEY secret present in the GitHub 3 | # repository or organization. 4 | # 5 | # See: https://github.com/marketplace/actions/publish-ansible-role-to-galaxy 6 | # See: https://github.com/ansible/galaxy/issues/46 7 | 8 | name: Release 9 | 'on': 10 | push: 11 | tags: 12 | - '*' 13 | 14 | defaults: 15 | run: 16 | working-directory: 'geerlingguy.gogs' 17 | 18 | jobs: 19 | 20 | release: 21 | name: Release 22 | runs-on: ubuntu-latest 23 | steps: 24 | - name: Check out the codebase. 25 | uses: actions/checkout@v2 26 | with: 27 | path: 'geerlingguy.gogs' 28 | 29 | - name: Set up Python 3. 30 | uses: actions/setup-python@v2 31 | with: 32 | python-version: '3.x' 33 | 34 | - name: Install Ansible. 35 | run: pip3 install ansible-base 36 | 37 | - name: Trigger a new import on Galaxy. 38 | run: ansible-galaxy role import --api-key ${{ secrets.GALAXY_API_KEY }} $(echo ${{ github.repository }} | cut -d/ -f1) $(echo ${{ github.repository }} | cut -d/ -f2) 39 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.retry 2 | */__pycache__ 3 | *.pyc 4 | .cache 5 | 6 | -------------------------------------------------------------------------------- /.yamllint: -------------------------------------------------------------------------------- 1 | --- 2 | extends: default 3 | 4 | rules: 5 | line-length: 6 | max: 120 7 | level: warning 8 | 9 | ignore: | 10 | .github/stale.yml 11 | .travis.yml 12 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2017 Jeff Geerling 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Ansible Role: Gogs 2 | 3 | **DEPRECATED**: This project is no longer actively maintained. I recommend using an alternative like [Gitea](https://gitea.com). 4 | 5 | [![CI](https://github.com/geerlingguy/ansible-role-gogs/workflows/CI/badge.svg?event=push)](https://github.com/geerlingguy/ansible-role-gogs/actions?query=workflow%3ACI) 6 | 7 | Installs [Gogs](https://github.com/gogits/gogs), a Go-based front-end to Git, on RedHat or Debian-based linux systems. 8 | 9 | After the playbook is finished, visit the gogs server (on port 3000 by default), and you will be redirected to the /install page, where you can configure an administrator account and other default options. 10 | 11 | ## Requirements 12 | 13 | Requires git (via `geerlingguy.git`), and at least the Gogs HTTP port (3000 by default) open on your system's firewall. Install MySQL (e.g. via `geerlingguy.mysql`) prior to installing Gogs if you would like to use MySQL instead of built-in SQLite support. 14 | 15 | ## Role Variables 16 | 17 | Available variables are listed below, along with default values (see `defaults/main.yml`): 18 | 19 | gogs_user: git 20 | gogs_user_home: /home/git 21 | 22 | The user and home under which Gogs will run and be installed. 23 | 24 | gogs_binary_url: https://github.com/gogits/gogs/releases/download/v0.3.1/linux_amd64.zip 25 | 26 | Download URL for the Gogs binary. 27 | 28 | gogs_http_port: "3000" 29 | 30 | HTTP port over which Gogs will be accessed. 31 | 32 | gogs_use_mysql: false 33 | gogs_db_name: gogs 34 | gogs_db_username: gogs 35 | gogs_db_password: root 36 | 37 | MySQL database support. Set `gogs_use_mysql` to `true` to configure MySQL for gogs, using the database name, username, and password defined by the respective variables. 38 | 39 | ## Dependencies 40 | 41 | - geerlingguy.git 42 | 43 | ## Example Playbook 44 | 45 | - hosts: servers 46 | vars_files: 47 | - vars/main.yml 48 | roles: 49 | - geerlingguy.gogs 50 | 51 | *Inside `vars/main.yml`*: 52 | 53 | gogs_http_port: "8080" 54 | 55 | ## License 56 | 57 | MIT / BSD 58 | 59 | ## Author Information 60 | 61 | This role was created in 2014 by [Jeff Geerling](https://www.jeffgeerling.com/), author of [Ansible for DevOps](https://www.ansiblefordevops.com/). 62 | -------------------------------------------------------------------------------- /defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | gogs_user: git 3 | gogs_user_home: /home/git 4 | gogs_binary_url: https://github.com/gogits/gogs/releases/download/v0.9.97/linux_amd64.tar.gz 5 | gogs_http_port: "3000" 6 | gogs_use_mysql: false 7 | gogs_db_name: gogs 8 | gogs_db_username: gogs 9 | gogs_db_password: root 10 | -------------------------------------------------------------------------------- /handlers/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: restart gogs 3 | service: name=gogs state=restarted 4 | -------------------------------------------------------------------------------- /meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | dependencies: 3 | - geerlingguy.git 4 | 5 | galaxy_info: 6 | role_name: gogs 7 | author: geerlingguy 8 | description: "Gogs: Go Git Service" 9 | company: "Midwestern Mac, LLC" 10 | license: "license (BSD, MIT)" 11 | min_ansible_version: 1.8 12 | platforms: 13 | - name: EL 14 | versions: 15 | - 7 16 | - name: Ubuntu 17 | versions: 18 | - all 19 | - name: Debian 20 | versions: 21 | - all 22 | galaxy_tags: 23 | - development 24 | - web 25 | - git 26 | - gogs 27 | - repository 28 | -------------------------------------------------------------------------------- /molecule/default/converge.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Converge 3 | hosts: all 4 | become: true 5 | 6 | pre_tasks: 7 | - name: Update apt cache. 8 | apt: update_cache=true cache_valid_time=600 9 | when: ansible_os_family == 'Debian' 10 | changed_when: false 11 | 12 | roles: 13 | - role: geerlingguy.git 14 | - role: geerlingguy.gogs 15 | -------------------------------------------------------------------------------- /molecule/default/molecule.yml: -------------------------------------------------------------------------------- 1 | --- 2 | dependency: 3 | name: galaxy 4 | driver: 5 | name: docker 6 | platforms: 7 | - name: instance 8 | image: "geerlingguy/docker-${MOLECULE_DISTRO:-centos7}-ansible:latest" 9 | command: ${MOLECULE_DOCKER_COMMAND:-""} 10 | volumes: 11 | - /sys/fs/cgroup:/sys/fs/cgroup:ro 12 | privileged: true 13 | pre_build_image: true 14 | provisioner: 15 | name: ansible 16 | playbooks: 17 | converge: ${MOLECULE_PLAYBOOK:-converge.yml} 18 | -------------------------------------------------------------------------------- /molecule/default/requirements.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - src: geerlingguy.git 3 | -------------------------------------------------------------------------------- /tasks/gogs-mysql.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Create Gogs MySQL user. 3 | mysql_user: 4 | name: "{{ gogs_db_username }}" 5 | host: "{{ item }}" 6 | priv: "{{ gogs_db_name }}.*:ALL" 7 | password: "{{ gogs_db_password }}" 8 | with_items: 9 | - 127.0.0.1 10 | - ::1 11 | - localhost 12 | when: gogs_use_mysql 13 | notify: restart gogs 14 | 15 | - name: Create Gogs MySQL database. 16 | mysql_db: 17 | db: "{{ gogs_db_name }}" 18 | state: present 19 | when: gogs_use_mysql 20 | notify: restart gogs 21 | -------------------------------------------------------------------------------- /tasks/init-setup.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Make Gogs init script executable. 3 | file: 4 | path: "{{ gogs_user_home }}/{{ gogs_init_script_path }}" 5 | mode: 0755 6 | 7 | - name: Symlink Gogs binary and startup scripts. 8 | file: # noqa 208 9 | src: "{{ item.src }}" 10 | dest: "{{ item.dest }}" 11 | state: link 12 | with_items: 13 | - src: "{{ gogs_user_home }}/gogs/gogs" 14 | dest: "/usr/local/bin/gogs" 15 | - src: "{{ gogs_user_home }}/{{ gogs_init_script_path }}" 16 | dest: "/etc/init.d/gogs" 17 | notify: restart gogs 18 | 19 | - name: Copy Gogs systemd unit file into place (for systemd systems). 20 | template: 21 | src: gogs.unit.j2 22 | dest: /etc/systemd/system/gogs.service 23 | owner: root 24 | group: root 25 | mode: 0755 26 | when: "ansible_service_mgr == 'systemd'" 27 | -------------------------------------------------------------------------------- /tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Include variables and define needed variables. 3 | - name: Include OS-specific variables. 4 | include_vars: "{{ ansible_os_family }}.yml" 5 | 6 | - name: Ensure unzip is installed. 7 | package: name=unzip state=present 8 | 9 | - name: Create user for Gogs. 10 | user: 11 | name: "{{ gogs_user }}" 12 | comment: Gogs 13 | home: "{{ gogs_user_home }}" 14 | 15 | - name: Check if Gogs is already installed. 16 | stat: path=/usr/local/bin/gogs 17 | register: gogs_bin 18 | 19 | - name: Download Gogs. 20 | get_url: 21 | url: "{{ gogs_binary_url }}" 22 | dest: "{{ gogs_user_home }}/gogs.zip" 23 | owner: "{{ gogs_user }}" 24 | group: "{{ gogs_user }}" 25 | when: gogs_bin.stat.islnk is not defined 26 | 27 | - name: Expand Gogs. 28 | unarchive: 29 | src: "{{ gogs_user_home }}/gogs.zip" 30 | dest: "{{ gogs_user_home }}" 31 | group: "{{ gogs_user }}" 32 | owner: "{{ gogs_user }}" 33 | copy: false 34 | mode: 0755 35 | when: gogs_bin.stat.islnk is not defined 36 | 37 | - include: init-setup.yml 38 | - include: gogs-mysql.yml 39 | 40 | - name: Create Gogs log folder. 41 | file: 42 | path: "{{ gogs_user_home }}/gogs/log" 43 | state: directory 44 | owner: "{{ gogs_user }}" 45 | group: "{{ gogs_user }}" 46 | mode: 0755 47 | 48 | - name: Ensure Gogs is running. 49 | service: name=gogs state=started enabled=yes 50 | -------------------------------------------------------------------------------- /templates/gogs.unit.j2: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Gogs (Go Git Service) 3 | After=syslog.target 4 | After=network.target 5 | #After=mysqld.service 6 | #After=postgresql.service 7 | #After=memcached.service 8 | #After=redis.service 9 | 10 | [Service] 11 | # Modify these two values and uncomment them if you have 12 | # repos with lots of files and get an HTTP error 500 because 13 | # of that 14 | ### 15 | #LimitMEMLOCK=infinity 16 | #LimitNOFILE=65535 17 | Type=simple 18 | User={{ gogs_user }} 19 | Group={{ gogs_user }} 20 | WorkingDirectory={{ gogs_user_home }}/gogs 21 | ExecStart={{ gogs_user_home }}/gogs/gogs web 22 | Restart=always 23 | Environment=USER={{ gogs_user }} HOME={{ gogs_user_home }} 24 | 25 | [Install] 26 | WantedBy=multi-user.target 27 | -------------------------------------------------------------------------------- /vars/Debian.yml: -------------------------------------------------------------------------------- 1 | --- 2 | gogs_init_script_path: gogs/scripts/init/debian/gogs 3 | -------------------------------------------------------------------------------- /vars/RedHat.yml: -------------------------------------------------------------------------------- 1 | --- 2 | gogs_init_script_path: gogs/scripts/init/centos/gogs 3 | --------------------------------------------------------------------------------