Joseph Pisciotta
2018-08-30 791ee8b9d59b919360158eb0d932db5f078dedc7
Add Gogs Install and Configuration to CICD Server
34 files added
3 files modified
677 ■■■■■ changed files
ansible/configs/ansible-cicd-lab/env_vars.yml 8 ●●●● patch | view | raw | blame | history
ansible/configs/ansible-cicd-lab/post_software.yml 3 ●●●● patch | view | raw | blame | history
ansible/roles/geerlingguy.git/.gitignore 2 ●●●●● patch | view | raw | blame | history
ansible/roles/geerlingguy.git/.travis.yml 59 ●●●●● patch | view | raw | blame | history
ansible/roles/geerlingguy.git/LICENSE 20 ●●●●● patch | view | raw | blame | history
ansible/roles/geerlingguy.git/README.md 55 ●●●●● patch | view | raw | blame | history
ansible/roles/geerlingguy.git/defaults/main.yml 23 ●●●●● patch | view | raw | blame | history
ansible/roles/geerlingguy.git/meta/.galaxy_install_info 1 ●●●● patch | view | raw | blame | history
ansible/roles/geerlingguy.git/meta/main.yml 29 ●●●●● patch | view | raw | blame | history
ansible/roles/geerlingguy.git/tasks/install-from-source.yml 70 ●●●●● patch | view | raw | blame | history
ansible/roles/geerlingguy.git/tasks/main.yml 23 ●●●●● patch | view | raw | blame | history
ansible/roles/geerlingguy.git/tests/README.md 11 ●●●●● patch | view | raw | blame | history
ansible/roles/geerlingguy.git/tests/test-source.yml 16 ●●●●● patch | view | raw | blame | history
ansible/roles/geerlingguy.git/tests/test.yml 15 ●●●●● patch | view | raw | blame | history
ansible/roles/geerlingguy.git/vars/Debian.yml 10 ●●●●● patch | view | raw | blame | history
ansible/roles/geerlingguy.git/vars/Fedora.yml 13 ●●●●● patch | view | raw | blame | history
ansible/roles/geerlingguy.git/vars/RedHat.yml 12 ●●●●● patch | view | raw | blame | history
ansible/roles/geerlingguy.git/vars/main.yml 3 ●●●●● patch | view | raw | blame | history
ansible/roles/geerlingguy.gogs/.gitignore 2 ●●●●● patch | view | raw | blame | history
ansible/roles/geerlingguy.gogs/.travis.yml 27 ●●●●● patch | view | raw | blame | history
ansible/roles/geerlingguy.gogs/LICENSE 20 ●●●●● patch | view | raw | blame | history
ansible/roles/geerlingguy.gogs/README.md 59 ●●●●● patch | view | raw | blame | history
ansible/roles/geerlingguy.gogs/defaults/main.yml 9 ●●●●● patch | view | raw | blame | history
ansible/roles/geerlingguy.gogs/handlers/main.yml 3 ●●●●● patch | view | raw | blame | history
ansible/roles/geerlingguy.gogs/meta/.galaxy_install_info 1 ●●●● patch | view | raw | blame | history
ansible/roles/geerlingguy.gogs/meta/main.yml 24 ●●●●● patch | view | raw | blame | history
ansible/roles/geerlingguy.gogs/tasks/gogs-mysql.yml 20 ●●●●● patch | view | raw | blame | history
ansible/roles/geerlingguy.gogs/tasks/init-setup.yml 24 ●●●●● patch | view | raw | blame | history
ansible/roles/geerlingguy.gogs/tasks/main.yml 48 ●●●●● patch | view | raw | blame | history
ansible/roles/geerlingguy.gogs/templates/gogs.unit.j2 26 ●●●●● patch | view | raw | blame | history
ansible/roles/geerlingguy.gogs/tests/README.md 11 ●●●●● patch | view | raw | blame | history
ansible/roles/geerlingguy.gogs/tests/requirements.yml 2 ●●●●● patch | view | raw | blame | history
ansible/roles/geerlingguy.gogs/tests/test.yml 14 ●●●●● patch | view | raw | blame | history
ansible/roles/geerlingguy.gogs/vars/Debian.yml 2 ●●●●● patch | view | raw | blame | history
ansible/roles/geerlingguy.gogs/vars/RedHat.yml 2 ●●●●● patch | view | raw | blame | history
ansible/roles/host-gogs-server/tasks/main.yml 9 ●●●●● patch | view | raw | blame | history
ansible/roles/host-gogs-server/templates/gogs_config.j2 1 ●●●● patch | view | raw | blame | history
ansible/configs/ansible-cicd-lab/env_vars.yml
@@ -277,4 +277,10 @@
tower_job_template_name: Acme
tower_credential_name: Acme
tower_job_template_playbook: hackathons/rhte-2018-emea/ansible-role-httpd/tests/test.yml
tower_credential_username: ec2-user
tower_credential_username: ec2-user
### Gogs Variables
ansible_service_mgr: systemd
gogs_admin_username: cicduser1
gogs_admin_password: r3dh4t!
ansible/configs/ansible-cicd-lab/post_software.yml
@@ -12,7 +12,7 @@
  hosts:
    - cicd*
  become: true
  gather_facts: False
  gather_facts: True
  vars_files:
    - "{{ ANSIBLE_REPO_PATH }}/configs/{{ env_type }}/env_vars.yml"
    - "{{ ANSIBLE_REPO_PATH }}/configs/{{ env_type }}/env_secret_vars.yml"
@@ -23,6 +23,7 @@
      setup:
        filter: 'ansible_[od][si]*'
  roles:
    - { role: "{{ ANSIBLE_REPO_PATH }}/roles/geerlingguy.gogs" }
    - { role: "{{ ANSIBLE_REPO_PATH }}/roles/host-gogs-server" }
    - { role: "{{ ANSIBLE_REPO_PATH }}/roles/host-jenkins-server" }
    - { role: "{{ ANSIBLE_REPO_PATH }}/roles/molecule" }
ansible/roles/geerlingguy.git/.gitignore
New file
@@ -0,0 +1,2 @@
*.retry
tests/test.sh
ansible/roles/geerlingguy.git/.travis.yml
New file
@@ -0,0 +1,59 @@
---
services: docker
env:
  # Test source install on latest supported OSes.
  - distro: centos7
    playbook: test-source.yml
    GIT_VERSION: 2.16.2
  - distro: fedora27
    playbook: test-source.yml
    GIT_VERSION: 2.16.2
  - distro: ubuntu1804
    playbook: test-source.yml
    GIT_VERSION: 2.16.2
  # Test package install on all supported OSes.
  - distro: centos7
    playbook: test.yml
    GIT_VERSION: 1.8.3.1
  - distro: centos6
    playbook: test.yml
    GIT_VERSION: 1.7.1
  - distro: fedora27
    playbook: test.yml
    GIT_VERSION: 2.14.3
  - distro: ubuntu1804
    playbook: test.yml
    GIT_VERSION: 2.15.1
  - distro: ubuntu1604
    playbook: test.yml
    GIT_VERSION: 2.7.4
  - distro: ubuntu1404
    playbook: test.yml
    GIT_VERSION: 1.9.1
  - distro: debian8
    playbook: test.yml
    GIT_VERSION: 2.1.4
script:
  # Configure test script so we can run extra tests after playbook is run.
  - export container_id=$(date +%s)
  - export cleanup=false
  # Download test shim.
  - wget -O ${PWD}/tests/test.sh https://gist.githubusercontent.com/geerlingguy/73ef1e5ee45d8694570f334be385e181/raw/
  - chmod +x ${PWD}/tests/test.sh
  # Run tests.
  - ${PWD}/tests/test.sh
  # Ensure Git is installed and at the right version.
  - 'docker exec --tty ${container_id} env TERM=xterm which git'
  - 'docker exec --tty ${container_id} env TERM=xterm test -x /usr/bin/git'
  - 'docker exec --tty ${container_id} env TERM=xterm git --version'
  - 'docker exec --tty ${container_id} env TERM=xterm /usr/bin/git --version | grep -qF "$GIT_VERSION"'
notifications:
  webhooks: https://galaxy.ansible.com/api/v1/notifications/
ansible/roles/geerlingguy.git/LICENSE
New file
@@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) 2017 Jeff Geerling
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
ansible/roles/geerlingguy.git/README.md
New file
@@ -0,0 +1,55 @@
# Ansible Role: Git
[![Build Status](https://travis-ci.org/geerlingguy/ansible-role-git.svg?branch=master)](https://travis-ci.org/geerlingguy/ansible-role-git)
Installs Git, a distributed version control system, on any RHEL/CentOS or Debian/Ubuntu Linux system.
## Requirements
None.
## Role Variables
Available variables are listed below, along with default values (see `defaults/main.yml`):
    workspace: /root
Where certain files will be downloaded and adjusted prior to git installation, if needed.
    git_enablerepo: ""
This variable, a well as `git_packages`, will be used to install git via a particular `yum` repo if `git_install_from_source` is false (CentOS only). Any additional repositories you have installed that you would like to use for a newer/different Git version.
    git_packages:
      - git
      - git-svn
The specific Git packages that will be installed. By default, `git-svn` is included, but you can easily add this variable to your playbook's variables and remove `git-svn` if desired.
    git_install_from_source: false
    git_install_path: "/usr"
    git_version: "2.16.2"
Whether to install Git from source; if set to `true`, `git_version` is required and will be used to install a particular version of git (see all available versions here: https://www.kernel.org/pub/software/scm/git/), and `git_install_path` defines where git should be installed.
    git_install_from_source_force_update: false
If git is already installed at and older version, force a new source build. Only applies if `git_install_from_source` is `true`.
## Dependencies
None.
## Example Playbook
    - hosts: servers
      roles:
        - { role: geerlingguy.git }
## License
MIT / BSD
## Author Information
This role was created in 2014 by [Jeff Geerling](https://www.jeffgeerling.com/), author of [Ansible for DevOps](https://www.ansiblefordevops.com/).
ansible/roles/geerlingguy.git/defaults/main.yml
New file
@@ -0,0 +1,23 @@
---
workspace: /root
# If git_install_from_source is set to false, these two variables define whether
# to use an additional repo for the package installation, and which git packages
# will be installed.
git_enablerepo: ""
git_packages:
  - git
  - git-svn
# If set to TRUE, git will be installed from source, using the version set with
# the 'git_version' variable instead of using a package.
git_install_from_source: false
git_install_path: "/usr"
git_version: "2.16.2"
# If git is already installed at and older version, force a new source build.
# Only applies if git_install_from_source is `true`.
git_install_from_source_force_update: false
# Leave this at it's default.
git_reinstall_from_source: false
ansible/roles/geerlingguy.git/meta/.galaxy_install_info
New file
@@ -0,0 +1 @@
{install_date: 'Thu Aug 30 16:27:09 2018', version: 2.0.2}
ansible/roles/geerlingguy.git/meta/main.yml
New file
@@ -0,0 +1,29 @@
---
dependencies: []
galaxy_info:
  author: geerlingguy
  description: Git version control software
  company: "Midwestern Mac, LLC"
  license: "license (BSD, MIT)"
  min_ansible_version: 2.4
  platforms:
  - name: EL
    versions:
    - all
  - name: Fedora
    versions:
    - all
  - name: Debian
    versions:
    - all
  - name: Ubuntu
    versions:
    - all
  galaxy_tags:
    - development
    - system
    - git
    - vcs
    - source
    - code
ansible/roles/geerlingguy.git/tasks/install-from-source.yml
New file
@@ -0,0 +1,70 @@
---
- name: Include OS-specific variables (RedHat).
  include_vars: "{{ ansible_os_family }}.yml"
  when:
    - ansible_os_family == "RedHat"
    - ansible_distribution != "Fedora"
- name: Include OS-specific variables (Fedora).
  include_vars: "{{ ansible_distribution }}.yml"
  when: ansible_distribution == "Fedora"
- name: Include OS-specific variables (Debian).
  include_vars: "{{ ansible_os_family }}.yml"
  when: ansible_os_family == "Debian"
- name: Define git_install_from_source_dependencies.
  set_fact:
    git_install_from_source_dependencies: "{{ __git_install_from_source_dependencies | list }}"
  when: git_install_from_source_dependencies is not defined
- name: Ensure git's dependencies are installed (RedHat).
  package: "name={{ item }} state=present"
  with_items: "{{ git_install_from_source_dependencies }}"
  when: ansible_os_family == 'RedHat'
- name: Ensure git's dependencies are installed (Debian).
  apt: "name={{ item }} state=present"
  with_items: "{{ git_install_from_source_dependencies }}"
  when: ansible_os_family == 'Debian'
- name: Get installed version.
  command: >
    git --version
    warn=no
  changed_when: false
  failed_when: false
  check_mode: no
  register: git_installed_version
- name: Force git install if the version numbers do not match.
  set_fact:
    git_reinstall_from_source: true
  when:
    - git_install_from_source_force_update
    - (git_installed_version.rc == 0) and (git_installed_version.stdout | regex_replace("^.*?([0-9\.]+)$", "\\1") | version_compare(git_version, operator="!="))
- name: Download git.
  get_url:
    url: "https://www.kernel.org/pub/software/scm/git/git-{{ git_version }}.tar.gz"
    dest: "{{ workspace }}/git-{{ git_version }}.tar.gz"
  when: (git_installed_version.rc != 0) or git_reinstall_from_source
- name: Expand git archive.
  unarchive:
    src: "{{ workspace }}/git-{{ git_version }}.tar.gz"
    dest: "{{ workspace }}"
    creates: "{{ workspace }}/git-{{ git_version }}/README"
    copy: no
  when: (git_installed_version.rc != 0) or git_reinstall_from_source
- name: Build git.
  command: >
    make prefix={{ git_install_path }} {{ item }}
    chdir={{ workspace }}/git-{{ git_version }}
  with_items:
    - all
    - install
  when: (git_installed_version.rc != 0) or git_reinstall_from_source
  become: yes
ansible/roles/geerlingguy.git/tasks/main.yml
New file
@@ -0,0 +1,23 @@
---
- name: Ensure git is installed (RedHat).
  package:
    name: "{{ item }}"
    state: present
    enablerepo: "{{ git_enablerepo }}"
  with_items: "{{ git_packages }}"
  when: (git_install_from_source == false) and (ansible_os_family == 'RedHat')
- name: Update apt cache (Debian).
  apt: update_cache=yes cache_valid_time=86400
  when: ansible_os_family == 'Debian'
- name: Ensure git is installed (Debian).
  apt:
    name: "{{ item }}"
    state: present
  with_items: "{{ git_packages }}"
  when: (git_install_from_source == false) and (ansible_os_family == 'Debian')
# Install git from source when git_install_from_source is true.
- import_tasks: install-from-source.yml
  when: git_install_from_source == true
ansible/roles/geerlingguy.git/tests/README.md
New file
@@ -0,0 +1,11 @@
# Ansible Role tests
To run the test playbook(s) in this directory:
  1. Install and start Docker.
  1. Download the test shim (see .travis.yml file for the URL) into `tests/test.sh`:
    - `wget -O tests/test.sh https://gist.githubusercontent.com/geerlingguy/73ef1e5ee45d8694570f334be385e181/raw/`
  1. Make the test shim executable: `chmod +x tests/test.sh`.
  1. Run (from the role root directory) `distro=[distro] playbook=[playbook] ./tests/test.sh`
If you don't want the container to be automatically deleted after the test playbook is run, add the following environment variables: `cleanup=false container_id=$(date +%s)`
ansible/roles/geerlingguy.git/tests/test-source.yml
New file
@@ -0,0 +1,16 @@
---
- hosts: all
  vars:
    git_install_from_source: true
    git_install_from_source_force_update: true
    git_version: "2.16.2"
  pre_tasks:
    - name: Update apt cache.
      apt: update_cache=yes cache_valid_time=600
      when: ansible_os_family == 'Debian'
      changed_when: false
  roles:
    - role_under_test
ansible/roles/geerlingguy.git/tests/test.yml
New file
@@ -0,0 +1,15 @@
---
- hosts: all
  vars:
    git_install_from_source: false
    git_install_path: /usr/local
  pre_tasks:
    - name: Update apt cache.
      apt: update_cache=yes cache_valid_time=600
      when: ansible_os_family == 'Debian'
      changed_when: false
  roles:
    - role_under_test
ansible/roles/geerlingguy.git/vars/Debian.yml
New file
@@ -0,0 +1,10 @@
---
git_install_from_source_dependencies:
  - libcurl4-gnutls-dev
  - libexpat1-dev
  - gettext
  - libssl-dev
  - zlib1g-dev
  - build-essential
  - gcc
ansible/roles/geerlingguy.git/vars/Fedora.yml
New file
@@ -0,0 +1,13 @@
---
git_install_from_source_dependencies:
  - gettext-devel
  - expat-devel
  - curl-devel
  - zlib-devel
  - perl-devel
  - openssl-devel
  - subversion-perl
  - make
  - gcc
  - tar
ansible/roles/geerlingguy.git/vars/RedHat.yml
New file
@@ -0,0 +1,12 @@
---
git_install_from_source_dependencies:
  - gettext-devel
  - expat-devel
  - curl-devel
  - zlib-devel
  - perl-devel
  - openssl-devel
  - subversion-perl
  - make
  - gcc
ansible/roles/geerlingguy.git/vars/main.yml
New file
@@ -0,0 +1,3 @@
---
# This space intentionally left blank.
ansible/roles/geerlingguy.gogs/.gitignore
New file
@@ -0,0 +1,2 @@
*.retry
tests/test.sh
ansible/roles/geerlingguy.gogs/.travis.yml
New file
@@ -0,0 +1,27 @@
---
services: docker
env:
  - distro: centos7
  - distro: ubuntu1604
  - distro: ubuntu1404
  - distro: ubuntu1204
  - distro: debian8
script:
  # Configure test script so we can run extra tests after playbook is run.
  - export container_id=$(date +%s)
  - export cleanup=false
  # Download test shim.
  - wget -O ${PWD}/tests/test.sh https://gist.githubusercontent.com/geerlingguy/73ef1e5ee45d8694570f334be385e181/raw/
  - chmod +x ${PWD}/tests/test.sh
  # Run tests.
  - ${PWD}/tests/test.sh
  # Check if we get an installation page.
  - 'docker exec --tty ${container_id} env TERM=xterm curl http://localhost:3000/install'
notifications:
  webhooks: https://galaxy.ansible.com/api/v1/notifications/
ansible/roles/geerlingguy.gogs/LICENSE
New file
@@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) 2017 Jeff Geerling
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
ansible/roles/geerlingguy.gogs/README.md
New file
@@ -0,0 +1,59 @@
# Ansible Role: Gogs
[![Build Status](https://travis-ci.org/geerlingguy/ansible-role-gogs.svg?branch=master)](https://travis-ci.org/geerlingguy/ansible-role-gogs)
Installs [Gogs](https://github.com/gogits/gogs), a Go-based front-end to Git, on RedHat or Debian-based linux systems.
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.
## Requirements
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.
## Role Variables
Available variables are listed below, along with default values (see `defaults/main.yml`):
    gogs_user: git
    gogs_user_home: /home/git
The user and home under which Gogs will run and be installed.
    gogs_binary_url: https://github.com/gogits/gogs/releases/download/v0.3.1/linux_amd64.zip
Download URL for the Gogs binary.
    gogs_http_port: "3000"
HTTP port over which Gogs will be accessed.
    gogs_use_mysql: false
    gogs_db_name: gogs
    gogs_db_username: gogs
    gogs_db_password: root
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.
## Dependencies
  - geerlingguy.git
## Example Playbook
    - hosts: servers
      vars_files:
        - vars/main.yml
      roles:
        - geerlingguy.gogs
*Inside `vars/main.yml`*:
    gogs_http_port: "8080"
## License
MIT / BSD
## Author Information
This role was created in 2014 by [Jeff Geerling](https://www.jeffgeerling.com/), author of [Ansible for DevOps](https://www.ansiblefordevops.com/).
ansible/roles/geerlingguy.gogs/defaults/main.yml
New file
@@ -0,0 +1,9 @@
---
gogs_user: git
gogs_user_home: /home/git
gogs_binary_url: https://github.com/gogits/gogs/releases/download/v0.9.97/linux_amd64.tar.gz
gogs_http_port: "3000"
gogs_use_mysql: false
gogs_db_name: gogs
gogs_db_username: gogs
gogs_db_password: root
ansible/roles/geerlingguy.gogs/handlers/main.yml
New file
@@ -0,0 +1,3 @@
---
- name: restart gogs
  service: name=gogs state=restarted
ansible/roles/geerlingguy.gogs/meta/.galaxy_install_info
New file
@@ -0,0 +1 @@
{install_date: 'Thu Aug 30 16:27:17 2018', version: 1.4.2}
ansible/roles/geerlingguy.gogs/meta/main.yml
New file
@@ -0,0 +1,24 @@
---
dependencies:
  - geerlingguy.git
galaxy_info:
  author: geerlingguy
  description: "Gogs: Go Git Service"
  company: "Midwestern Mac, LLC"
  license: "license (BSD, MIT)"
  min_ansible_version: 1.8
  platforms:
  - name: EL
    versions:
    - 6
    - 7
  - name: Ubuntu
    versions:
    - all
  - name: Debian
    versions:
    - all
  galaxy_tags:
    - development
    - web
ansible/roles/geerlingguy.gogs/tasks/gogs-mysql.yml
New file
@@ -0,0 +1,20 @@
---
- name: Create Gogs MySQL user.
  mysql_user:
    name: "{{ gogs_db_username }}"
    host: "{{ item }}"
    priv: "{{ gogs_db_name }}.*:ALL"
    password: "{{ gogs_db_password }}"
  with_items:
    - 127.0.0.1
    - ::1
    - localhost
  when: gogs_use_mysql
  notify: restart gogs
- name: Create Gogs MySQL database.
  mysql_db:
    db: "{{ gogs_db_name }}"
    state: present
  when: gogs_use_mysql
  notify: restart gogs
ansible/roles/geerlingguy.gogs/tasks/init-setup.yml
New file
@@ -0,0 +1,24 @@
---
- name: Make Gogs init script executable.
  file:
    path: "{{ gogs_user_home }}/{{ gogs_init_script_path }}"
    mode: 0755
- name: Symlink Gogs binary and startup scripts.
  file:
    src: "{{ item.src }}"
    dest: "{{ item.dest }}"
    state: link
  with_items:
    - { src: "{{ gogs_user_home }}/gogs/gogs", dest: "/usr/local/bin/gogs" }
    - { src: "{{ gogs_user_home }}/{{ gogs_init_script_path }}" , dest: "/etc/init.d/gogs" }
  notify: restart gogs
- name: Copy Gogs systemd unit file into place (for systemd systems).
  template:
    src: gogs.unit.j2
    dest: /etc/systemd/system/gogs.service
    owner: root
    group: root
    mode: 0755
  when: "ansible_service_mgr == 'systemd'"
ansible/roles/geerlingguy.gogs/tasks/main.yml
New file
@@ -0,0 +1,48 @@
---
# Include variables and define needed variables.
- name: Include OS-specific variables.
  include_vars: "{{ ansible_os_family }}.yml"
- name: Ensure unzip is installed.
  package: name=unzip state=present
- name: Create user for Gogs.
  user:
    name: "{{ gogs_user }}"
    comment: Gogs
    home: "{{ gogs_user_home }}"
- name: Check if Gogs is already installed.
  stat: path=/usr/local/bin/gogs
  register: gogs_bin
- name: Download Gogs.
  get_url:
    url: "{{ gogs_binary_url }}"
    dest: "{{ gogs_user_home }}/gogs.zip"
    owner: "{{ gogs_user }}"
    group: "{{ gogs_user }}"
  when: gogs_bin.stat.islnk is not defined
- name: Expand Gogs.
  unarchive:
    src: "{{ gogs_user_home }}/gogs.zip"
    dest: "{{ gogs_user_home }}"
    group: "{{ gogs_user }}"
    owner: "{{ gogs_user }}"
    copy: no
  when: gogs_bin.stat.islnk is not defined
- include: init-setup.yml
- include: gogs-mysql.yml
- name: Create Gogs log folder.
  file:
    path: "{{ gogs_user_home }}/gogs/log"
    state: directory
    owner: "{{ gogs_user }}"
    group: "{{ gogs_user }}"
    mode: 0755
- name: Ensure Gogs is running.
  service: name=gogs state=started enabled=yes
ansible/roles/geerlingguy.gogs/templates/gogs.unit.j2
New file
@@ -0,0 +1,26 @@
[Unit]
Description=Gogs (Go Git Service)
After=syslog.target
After=network.target
#After=mysqld.service
#After=postgresql.service
#After=memcached.service
#After=redis.service
[Service]
# Modify these two values and uncomment them if you have
# repos with lots of files and get an HTTP error 500 because
# of that
###
#LimitMEMLOCK=infinity
#LimitNOFILE=65535
Type=simple
User={{ gogs_user }}
Group={{ gogs_user }}
WorkingDirectory={{ gogs_user_home }}/gogs
ExecStart={{ gogs_user_home }}/gogs/gogs web
Restart=always
Environment=USER={{ gogs_user }} HOME={{ gogs_user_home }}
[Install]
WantedBy=multi-user.target
ansible/roles/geerlingguy.gogs/tests/README.md
New file
@@ -0,0 +1,11 @@
# Ansible Role tests
To run the test playbook(s) in this directory:
  1. Install and start Docker.
  1. Download the test shim (see .travis.yml file for the URL) into `tests/test.sh`:
    - `wget -O tests/test.sh https://gist.githubusercontent.com/geerlingguy/73ef1e5ee45d8694570f334be385e181/raw/`
  1. Make the test shim executable: `chmod +x tests/test.sh`.
  1. Run (from the role root directory) `distro=[distro] playbook=[playbook] ./tests/test.sh`
If you don't want the container to be automatically deleted after the test playbook is run, add the following environment variables: `cleanup=false container_id=$(date +%s)`
ansible/roles/geerlingguy.gogs/tests/requirements.yml
New file
@@ -0,0 +1,2 @@
---
- src: geerlingguy.git
ansible/roles/geerlingguy.gogs/tests/test.yml
New file
@@ -0,0 +1,14 @@
- hosts: all
  pre_tasks:
    - name: Update apt cache.
      apt: update_cache=yes cache_valid_time=600
      when: ansible_os_family == 'Debian'
      changed_when: false
    - name: Ensure build dependencies are installed.
      package: name=curl state=present
  roles:
    - geerlingguy.git
    - role_under_test
ansible/roles/geerlingguy.gogs/vars/Debian.yml
New file
@@ -0,0 +1,2 @@
---
gogs_init_script_path: gogs/scripts/init/debian/gogs
ansible/roles/geerlingguy.gogs/vars/RedHat.yml
New file
@@ -0,0 +1,2 @@
---
gogs_init_script_path: gogs/scripts/init/centos/gogs
ansible/roles/host-gogs-server/tasks/main.yml
@@ -1,4 +1,7 @@
---
- name: Start host-jenkins-server installer
  debug:
    msg: "Do the needful to deploy host-jenkins-server"
- name: Run gogs Config with admin user creation
  uri:
    url: http://{{ ansible_hostname }}:3000/install
    method: POST
    body: "{{ lookup('template', 'templates/gogs_config.j2') }}"
    status_code: 302
ansible/roles/host-gogs-server/templates/gogs_config.j2
New file
@@ -0,0 +1 @@
db_type=SQLite3&db_path=data/gogs.db&app_name=Gogs&repo_root_path=/home/git/gogs-repositories&run_user=git&domain=example.opentlc.com&ssh_port=22&http_port=3000&app_url=http://localhost:3000/&log_root_path=/home/git/gogs/log&smtp_host=&smtp_from=&smtp_user=&smtp_passwd=&disable_gravatar=true&enable_captcha=false&register_confirm=false&admin_name={{ gogs_admin_username}}&admin_passwd={{ gogs_admin_password }}&admin_confirm_passwd={{ gogs_admin_password }}&admin_email=admin@example.com