Skip to content
Permalink
Browse files

s/gogs/gitea/g

  • Loading branch information
alvaroaleman committed Jan 1, 2017
1 parent 13a273d commit 66ccdf0524c651c01f6f7e5ca9b70c5901fbe8bb
Showing with 171 additions and 171 deletions.
  1. +26 −26 README.md
  2. +4 −4 Vagrantfile
  3. +19 −19 defaults/main.yml
  4. +8 −8 handlers/main.yml
  5. +1 −1 meta/main.yml
  6. +54 −54 tasks/main.yml
  7. +21 −21 templates/builtin_app.ini.j2
  8. +4 −4 templates/facts.j2
  9. +20 −0 templates/gitea.service.j2
  10. +0 −20 templates/gogs.service.j2
  11. +9 −9 tests/test.yml
  12. +5 −5 vars/main.yml
@@ -1,18 +1,18 @@
# ansible-gogs
# ansible-gitea

## Synopsis

```yml
- hosts: all
vars:
gogs_database_name: gogs
gogs_database_user: gogs
gogs_database_password: "{{ vault_crypted_gogs_database_pass }}"
gogs_salt: "{{ vault_crypted_gogs_salt }}"
gogs_domain: git.example.com
gogs_database_uri: mysql.example.com:3306
gitea_database_name: gitea
gitea_database_user: gitea
gitea_database_password: "{{ vault_crypted_gitea_database_pass }}"
gitea_salt: "{{ vault_crypted_gitea_salt }}"
gitea_domain: git.example.com
gitea_database_uri: mysql.example.com:3306
roles:
- alvaroaleman.gogs
- alvaroaleman.gitea
```

## Description
@@ -25,24 +25,24 @@ Simple role to install the Gogs git server.

## Role Variables

* ``gogs_domain``: The baseurl for linkgeneration ``mandatory``
* ``gogs_database_bassword``: Database password for gogs ``mandatory``
* ``gogs_salt``: The salt to use for password storage ``mandatory``
* ``gogs_database_uri``: Uri to use for database connection (default: ``localhost:3306``)
* ``gogs_database_name``: Name of the database gogs shall use (default: ``gogs``)
* ``gogs_database_user``: Name of the database usre gogs shall use (default: ``gogs``)
* ``gogs_database_type``: Type of gogs database (default: ``mysql``)
* ``gogs_http_port``: Http port gogs shall bind to (default: ``3000``)
* ``gogs_ssh_port``: SSH port gogs shall bind to (default: ``2222``)
* ``gogs_http_proto``: Whether to prepend ``http`` or ``https`` to generated links (default: ``http``)
* ``gogs_logdir``: The directory to write logs into (default: ``/var/run/gogs``)
* ``gogs_appini_template``: Template to use fot gogs ``app.ini`` config file (default: ``builtin_app.ini.j2``)
* ``gogs_home``: Folder in which to put gogs data (default: ``/srv/gogs``)
* ``gogs_username``: Username under which to run gogs. Must be root if you want gogs to bind to ports < 1024 (default: ``gogs``)
* ``gogs_install_dir``: Folder to install gogs into (default: ``/opts/gogs``)
* ``gogs_config_dir``: Folder in which to put gogs config (default: ``/etc/gogs``)
* ``gogs_version``: The version of gogs to install (default: ``0.9.113``)
* ``gogs_http_listen_addr``: The address to listen on for http request (default: '')
* ``gitea_domain``: The baseurl for linkgeneration ``mandatory``
* ``gitea_database_bassword``: Database password for gitea ``mandatory``
* ``gitea_salt``: The salt to use for password storage ``mandatory``
* ``gitea_database_uri``: Uri to use for database connection (default: ``localhost:3306``)
* ``gitea_database_name``: Name of the database gitea shall use (default: ``gitea``)
* ``gitea_database_user``: Name of the database usre gitea shall use (default: ``gitea``)
* ``gitea_database_type``: Type of gitea database (default: ``mysql``)
* ``gitea_http_port``: Http port gitea shall bind to (default: ``3000``)
* ``gitea_ssh_port``: SSH port gitea shall bind to (default: ``2222``)
* ``gitea_http_proto``: Whether to prepend ``http`` or ``https`` to generated links (default: ``http``)
* ``gitea_logdir``: The directory to write logs into (default: ``/var/run/gitea``)
* ``gitea_appini_template``: Template to use fot gitea ``app.ini`` config file (default: ``builtin_app.ini.j2``)
* ``gitea_home``: Folder in which to put gitea data (default: ``/srv/gitea``)
* ``gitea_username``: Username under which to run gitea. Must be root if you want gitea to bind to ports < 1024 (default: ``gitea``)
* ``gitea_install_dir``: Folder to install gitea into (default: ``/opts/gitea``)
* ``gitea_config_dir``: Folder in which to put gitea config (default: ``/etc/gitea``)
* ``gitea_version``: The version of gitea to install (default: ``0.9.113``)
* ``gitea_http_listen_addr``: The address to listen on for http request (default: '')


## Contributing
@@ -38,9 +38,9 @@ Vagrant.configure(VAGRANT_API_VERSION) do |config|
config.vm.box = ENV['ANSIBLE_GOGS_VAGRANT_BOXNAME'] || c['vm']['box']
config.vm.box_check_update = c['vm']['check_update']

config.vm.define :ansiblegogstest do |d|
config.vm.define :ansiblegiteatest do |d|

d.vm.hostname = 'ansiblegogstest'
d.vm.hostname = 'ansiblegiteatest'
if not c['vm']['synced_folders']
d.vm.synced_folder '.', '/vagrant', id: 'vagrant-root', disabled: true
d.vm.synced_folder '.', '/home/vagrant/sync', id: 'vagrant-root', disabled: true
@@ -56,7 +56,7 @@ Vagrant.configure(VAGRANT_API_VERSION) do |config|
# configure ansible-playbook
ansible.playbook = 'tests/test.yml'
ansible.groups = {
'vagrant' => ['ansiblegogstest']
'vagrant' => ['ansiblegiteatest']
}
ansible.limit = 'vagrant'

@@ -81,7 +81,7 @@ Vagrant.configure(VAGRANT_API_VERSION) do |config|

d.vm.provider :virtualbox do |v|
v.customize 'pre-boot', ['modifyvm', :id, '--nictype1', 'virtio']
v.customize [ 'modifyvm', :id, '--name', 'ansiblegogstest', '--memory', '1024', '--cpus', '1' ]
v.customize [ 'modifyvm', :id, '--name', 'ansiblegiteatest', '--memory', '1024', '--cpus', '1' ]
end

d.vm.provider :libvirt do |lv|
@@ -1,20 +1,20 @@
---
# defaults file for ansible-gogs
gogs_username: gogs
gogs_home: '/srv/gogs'
gogs_install_dir: '/opt/gogs'
gogs_config_dir: '/etc/gogs'
gogs_version: '0.9.113'
gogs_template_use_cow: "{{ util_template_use_cow|default(true) }}"
gogs_appini_template: builtin_app.ini.j2
gogs_logdir: /var/log/gogs
gogs_runmode: prod
gogs_http_proto: 'http'
gogs_domain: "{{ ansible_fqdn }}"
gogs_http_port: '3000'
gogs_ssh_port: '2222'
gogs_database_type: 'mysql'
gogs_database_uri: 'localhost:3306'
gogs_database_name: gogs
gogs_database_user: gogs
gogs_http_listen_addr: ''
# defaults file for ansible-gitea
gitea_username: gitea
gitea_home: '/srv/gitea'
gitea_install_dir: '/opt/gitea'
gitea_config_dir: '/etc/gitea'
gitea_version: '0.9.113'
gitea_template_use_cow: "{{ util_template_use_cow|default(true) }}"
gitea_appini_template: builtin_app.ini.j2
gitea_logdir: /var/log/gitea
gitea_runmode: prod
gitea_http_proto: 'http'
gitea_domain: "{{ ansible_fqdn }}"
gitea_http_port: '3000'
gitea_ssh_port: '2222'
gitea_database_type: 'mysql'
gitea_database_uri: 'localhost:3306'
gitea_database_name: gitea
gitea_database_user: gitea
gitea_http_listen_addr: ''
@@ -1,15 +1,15 @@
---
# handlers file for ansible-gogs
- name: service gogs restart
tags: gogs
# handlers file for ansible-gitea
- name: service gitea restart
tags: gitea
become: true
notify: Ensure gogs is running
notify: Ensure gitea is running
service:
name: gogs
name: gitea
state: restarted

- name: Ensure gogs is running
tags: gogs
- name: Ensure gitea is running
tags: gitea
changed_when: false
become: true
command: systemctl status gogs
command: systemctl status gitea
@@ -1,6 +1,6 @@
galaxy_info:
author: Alvaro Aleman
description: A role to install gogs
description: A role to install gitea
company: Silpion IT-Solutions GmbH

# If the issue tracker for your role is not on github, uncomment the
@@ -1,129 +1,129 @@
---
# tasks file for ansible-gogs
# tasks file for ansible-gitea
- name: Assert supported distribution
tags: gogs
tags: gitea
assert:
that: ansible_distribution + '-' + ansible_distribution_major_version in gogs_supported_distributions
that: ansible_distribution + '-' + ansible_distribution_major_version in gitea_supported_distributions

- name: Ensure sha256sum is available
tags: gogs
tags: gitea
assert:
that: gogs_sha256sum[gogs_version] is defined
that: gitea_sha256sum[gitea_version] is defined

- name: Create gogs user
tags: gogs
- name: Create gitea user
tags: gitea
become: true
user:
name: "{{ gogs_username }}"
home: "{{ gogs_home }}"
name: "{{ gitea_username }}"
home: "{{ gitea_home }}"
system: true

- name: Install prerequisites
tags: gogs
tags: gitea
become: true
package:
name: git
state: present

- name: Include datapersitency tasks
tags: gogs
tags: gitea
include: "{{ role_path }}/../silpion.lib/tasks/datapersistency.yml"

- name: Download gogs
tags: gogs
- name: Download gitea
tags: gitea
include: "{{ role_path }}/../silpion.lib/tasks/get_url.yml"
vars:
url: "https://cdn.gogs.io/gogs_v{{ gogs_version }}_linux_amd64.tar.gz"
filename: "{{ gogs_filename }}"
sha256sum: "{{ gogs_checksum }}"
url: "https://cdn.gogs.io/gogs_v{{ gitea_version }}_linux_amd64.tar.gz"
filename: "{{ gitea_filename }}"
sha256sum: "{{ gitea_checksum }}"

- name: Copy gogs
tags: gogs
- name: Copy gitea
tags: gitea
include: "{{ role_path }}/../silpion.lib/tasks/copy.yml"
vars:
filename: "{{ gogs_filename }}"
filename: "{{ gitea_filename }}"

- name: Create directorys
tags: gogs
tags: gitea
become: true
with_items:
- "{{ gogs_install_dir }}"
- "{{ gogs_install_dir ~ '/' ~ gogs_version }}"
- "{{ gogs_home ~ '/custom' }}"
- "{{ gogs_home ~ '/custom/data' }}"
- "{{ gogs_logdir }}"
- "{{ gogs_config_dir }}"
- "{{ gitea_install_dir }}"
- "{{ gitea_install_dir ~ '/' ~ gitea_version }}"
- "{{ gitea_home ~ '/custom' }}"
- "{{ gitea_home ~ '/custom/data' }}"
- "{{ gitea_logdir }}"
- "{{ gitea_config_dir }}"
file:
state: directory
path: "{{ item.path|default(item) }}"
owner: "{{ item.owner|default(gogs_username) }}"
group: "{{ item.group|default(gogs_username) }}"
owner: "{{ item.owner|default(gitea_username) }}"
group: "{{ item.group|default(gitea_username) }}"
mode: 0755

- name: Link config
tags: gogs
tags: gitea
become: true
file:
state: link
src: "{{ gogs_config_dir }}"
dest: "{{ gogs_home }}/custom/conf"
src: "{{ gitea_config_dir }}"
dest: "{{ gitea_home }}/custom/conf"

- name: Deploy config
tags: gogs
notify: service gogs restart
tags: gitea
notify: service gitea restart
become: true
template:
src: "{{ gogs_appini_template }}"
dest: "{{ gogs_config_dir }}/app.ini"
src: "{{ gitea_appini_template }}"
dest: "{{ gitea_config_dir }}/app.ini"
owner: 0
group: "{{ gogs_username }}"
group: "{{ gitea_username }}"
mode: 0640

- name: Install gogs
tags: gogs
- name: Install gitea
tags: gitea
become: true
command: >
tar -xzf {{ lib_persistent_data_path_remote }}/{{ gogs_filename }}
tar -xzf {{ lib_persistent_data_path_remote }}/{{ gitea_filename }}
--strip-components 1
--directory {{ gogs_install_dir ~ '/' ~ gogs_version }}
--directory {{ gitea_install_dir ~ '/' ~ gitea_version }}
--no-same-owner
args:
creates: "{{ gogs_install_dir ~ '/' ~ gogs_version ~ '/gogs' }}"
creates: "{{ gitea_install_dir ~ '/' ~ gitea_version ~ '/gitea' }}"

- name: Deploy unitfiles
tags: gogs
notify: service gogs restart
tags: gitea
notify: service gitea restart
become: true
register: registered_unitfiledeployment
template:
src: gogs.service.j2
dest: /etc/systemd/system/gogs.service
src: gitea.service.j2
dest: /etc/systemd/system/gitea.service

- name: Reload unitfiles
tags: gogs
tags: gitea
become: true
when: registered_unitfiledeployment|changed
command: systemctl daemon-reload

- name: Deploy facts
tags: gogs
tags: gitea
include: "{{ role_path }}/../silpion.lib/tasks/localfacts.yml"
vars:
template: facts.j2
namespace: gogs
namespace: gitea

- name: Ensure gogs service is enabled and started
tags: gogs
- name: Ensure gitea service is enabled and started
tags: gitea
become: true
notify: Ensure gogs is running
notify: Ensure gitea is running
service:
state: started
enabled: true
name: gogs
name: gitea

- name: Help user
debug:
msg: >
Find your gogs at http://{{ gogs_domain }}:3000
Find your gitea at http://{{ gitea_domain }}:3000
To create an initial user, you need to temporarily set
DISABLE_REGISTRATION=false in {{ gogs_config_dir }}/app.ini
DISABLE_REGISTRATION=false in {{ gitea_config_dir }}/app.ini

0 comments on commit 66ccdf0

Please sign in to comment.
You can’t perform that action at this time.