gogs

Install, configure and manage Gogs (Go Git Service) from binary instead of using any Thirdparty PPA´s.

Kevin Schu

kschu91

9,926 downloads

802 latest version

4.1 quality score

Version information

  • 1.5.0 (latest)
  • 1.4.0
  • 1.3.0
  • 1.2.0
  • 1.1.0
  • 1.0.1
  • 1.0.0
  • 0.2.0
  • 0.1.0
released Sep 24th 2020
This version is compatible with:
  • Puppet Enterprise 2017.2.x, 2017.1.x, 2016.5.x, 2016.4.x
  • Puppet >= 3.8.0 < 5.0.0
  • RedHat
    ,
    CentOS
    ,
    Debian
    ,
    Ubuntu
    ,
    OracleLinux

Start using this module

Tags: gogs, go, git, vcs

Documentation

kschu91/gogs — version 1.5.0 Sep 24th 2020

kschu91/gogs

Build Status Puppet Forge Puppet Forge - downloads Puppet Forge - scores puppetstats

Table of Contents

  1. Description
  2. Setup - The basics of getting started with gogs
  3. Usage - Configuration options and additional functionality
  4. Reference - An under-the-hood peek at what the module is doing and how
  5. Limitations - OS compatibility, etc.
  6. Development - Guide for contributing to the module

Description

This module install and configure Gogs (A painless self-hosted Git service.) by installing Gogs from binary instead of using any thirdparty PPA´s. You are completely free to configure Gogs for your needs since this module allows dynamic configuration for the custom/conf/app.in file.

Setup

What gogs affects

  • Gogs will be installed in /opt/gogs (can be changed).
  • A service will be installed with an init script.
  • By default a user and the correspendig group will be created (can be turned off).
  • By default curl, wget, tar, git will be installed if not already installed on your system (can be turned off).
  • On RedHat, CentOS and OracleLinux the initscripts package will be installed by default if not already done (can be turned off).

Setup Requirements

MySQL or PostgreSQL are not being installed by this module. Make sure those services are installed before using Gogs. Have a look at the prerequisites documentation of Gogs for a quick step into it.

Note: Currently puppet 3 and 4 is supported. But the support of puppet 3.x will be dropped in future versions of this module.

Beginning with gogs

You can simply include the gogs module to get started with the defaults. Check out the reference to see what the defaults are. After that you can visit Gogs via http://youhost.tld:3000 and you can follow the installation instructions from the gogs install tool.

include ::gogs

But be aware, if you change anything within gogs installation tool puppet will overwrite the app.ini on its next run. You rather should define all your configurations within puppet. A minimal setup with a mysql database should look like this:

class { '::gogs':
    app_ini_sections => {
        'database' => {
            'DB_TYPE' => 'mysql',
            'HOST'    => 'localhost:3306',
            'NAME'    => 'gogs',
            'USER'    => 'gogs',
            'PASSWD'  => 'mysecretpasswd',
        },
        'security' => {
            'SECRET_KEY' => 'mysecretkey',
            'INSTALL_LOCK' => true,
        },
    },
}

Note: You should always set INSTALL_LOCK configuration to true. Otherwise the installer is open for everyone.

Usage

The most common way of using the gogs module with a minimal set of custom configuration is the following.

Note: You are able to provide any available Gogs configuration in app_ini and app_ini_sections. For a complete list of available configuration have a look at the Gogs configuration cheat sheet.

class { '::gogs':
    app_ini => {
        'APP_NAME' => 'My Fancy GIT Service'
    },
    app_ini_sections => {
        'server'   => {
            'DOMAIN'    => 'git.example.com',
            'HTTP_PORT' => 8080,
        },
        'database' => {
            'DB_TYPE' => 'mysql',
            'HOST'    => 'localhost:3306',
            'NAME'    => 'gogs',
            'USER'    => 'gogs',
            'PASSWD'  => 'mysecretpasswd',
        },
        'security' => {
            'SECRET_KEY' => 'mysecretkey',
            'INSTALL_LOCK' => true,
        },
    },
}

Note: Currently the module will not create an admin user for you. You can do this by using the gogs cli: gogs admin create-user --name="john.doe" --password="supersecret" --email="john@doe.com" --admin

Reference

Parameters

version

You can specify a specific version. Just tell the module which version you want to install. For example 0.9.113. The default version is latest and the module will then fetch the latest version from Github automatically.

class { '::gogs':
    version => '0.9.113'
}

installation_directory

If you need to change the installation directory you can do this by specifieng this parameter. By default gogs will be installed in /opt/gogs

class { '::gogs':
    installation_directory => '/home/git/gogs'
}

repository_root

By default git repositories are stored in /var/git. Use this parameter to change the default path.

class { '::gogs':
    repository_root => '/home/git/gogs-repositories'
}

app_ini

A hash of available Gogs configuration. For a full list please have a look at the configuration cheat sheet.

class { '::gogs':
    app_ini => {
        'APP_NAME' => 'My Fancy GIT Service'
    },
}

app_ini_sections

Hash of available Gogs configurations that belong to a specific section. For a full list please have a look at the configuration cheat sheet.

class { '::gogs':
    app_ini_sections => {
        'server'   => {
            'DOMAIN'    => 'git.example.com',
            'HTTP_PORT' => 3000,
        },
        'database' => {
            'DB_TYPE' => 'mysql',
            'HOST'    => 'localhost:3306',
            'NAME'    => 'gogs',
            'USER'    => 'gogs',
            'PASSWD'  => 'mysecretpasswd',
        },
        'security' => {
            'SECRET_KEY' => 'mysecretkey',
        },
        'service'  => {
            'REQUIRE_SIGNIN_VIEW'  => true,
            'DISABLE_REGISTRATION' => true,
        },
    },
}

manage_user

Set this to false if you want to manage the user under which Gogs is running to handle by yourself. By default this is set to true and the module will create the user and the corresponding group.

class { '::gogs':
    manage_user => false
}

manage_packages

Set this to false if you want to manage the dependent packages by yourself. By default this is set to true and the module will install all the dependent packages by itself. The packages being installed are curl, wget, tar, git and on RedHat, CentOS and OracleLinux the initscripts package. If you set this to false make sure the packages are installed before using this module.

class { '::gogs':
    manage_packages => false
}

manage_home

Set this to false if you want to manage/create the users home directory by yourself. By default this is set to true and the module will create the users home directory for you. This parameter have no effect if manage_user is set to false. No home directory will then be created/managed by this module.

class { '::gogs':
    manage_home => false
}

owner

Use this parameter to change the user under which Gogs is running. By default the users name is git.

class { '::gogs':
    owner => 'johndoe'
}

group

Use this parameter to change the group under which Gogs is running. By default the group name is git.

class { '::gogs':
    group => 'company'
}

service_ensure

By default this parameter is set to running. Set it to stopped if you don´t want to start gogs by puppet.

class { '::gogs':
    service_ensure => 'stopped'
}

service_name

By default the service is named gogs. If you ever need to change that you can do this by setting this parameter. You should NOT change the service name after your first puppet run. Otherwise you may run into issues with two services and already blocked ports.

class { '::gogs':
    service_name => 'gogitsgogs'
}

log_path

By default the log_path points to the folder log relative to the installation_directory, which is /opt/gogs/log per default.

class { '::gogs':
    log_path => '/var/log/gogs'
}

Changing it to /var/log/gogs for example, will force gogs to write a gogs.log file in /var/log/gogs.

sysconfig

Normally there is no need to change this. But if you need to change variables for the daemon script anyways use this parameter. The provided variables are stored in a sysconfig file depending on your distribution and service name (e.g /etc/default/gogs) and are then automatically interpreted by the daemon scripts.

The configuration key to pass depends on your OS. For example on Debian the user variable is named USER and on CentOS it´s named GOGS_USER. Take a look into the provided init scripts of Gogs to make sure you pass the correct variables. Otherwise your service may fail silently.

class { '::gogs':
    sysconfig => {
        'NAME' => 'gogitsgogs',
        'USER' => 'johndoe',
    }
}

puppetstats_enabled

The gogs module is using puppetstats.com to ensure that the module is developed and maintained against it´s real usage, since I do not want to support old puppet versions when almost nobody is using them anymore. puppetstats.com tracks anonymous usage statistics of the puppet environment where gogs is running. By default puppetstats_enabled is set to true, but of course you can opt-out from that. Simply set puppetstats_enabled to false.

class { '::gogs':
    puppetstats_enabled => false
}

Limitations

This module is developed and tested on Ubuntu, Debian, CentOS and OracleLinux (RedHat should also work). But other distributions are currently not supported. Do not hesitate to create an issue on Github if you are facing any trouble.

Development

You are very welcome to contribute on this module. The source code is available on GitHub. Please follow the contributing instructions from puppet.