Skip to content

Commit

Permalink
steps to install gitlab
Browse files Browse the repository at this point in the history
add the tasks that will install gitlab
  • Loading branch information
kayiwa committed Oct 6, 2024
1 parent dc0f9e8 commit 65099ec
Show file tree
Hide file tree
Showing 11 changed files with 186 additions and 0 deletions.
38 changes: 38 additions & 0 deletions roles/gitlab/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
Role Name
=========

A brief description of the role goes here.

Requirements
------------

Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.

Role Variables
--------------

A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.

Dependencies
------------

A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.

Example Playbook
----------------

Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:

- hosts: servers
roles:
- { role: username.rolename, x: 42 }

License
-------

BSD

Author Information
------------------

An optional section for the role authors to include contact information, or a website (HTML is not allowed).
2 changes: 2 additions & 0 deletions roles/gitlab/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
# defaults file for roles/gitlab
9 changes: 9 additions & 0 deletions roles/gitlab/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
# handlers file for roles/gitlab
- name: Restart mail service
ansible.builtin.service:
name: postfix
state: restarted

- name: reconfigure gitlab
ansible.builtin.command: gitlab-ctl reconfigure
16 changes: 16 additions & 0 deletions roles/gitlab/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
galaxy_info:
role_name: gitlab
company: Princeton University Library
description: Install Gitlab CE
author: pulibrary

license: MIT

min_ansible_version: "2.9"

platforms:
- name: Ubuntu
versions:
- jammy
dependencies: []
15 changes: 15 additions & 0 deletions roles/gitlab/molecule/default/converge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
- name: Converge
hosts: all
vars:
- running_on_server: false
become: true
pre_tasks:
- name: Update cache
ansible.builtin.apt:
update_cache: true
cache_valid_time: 600
tasks:
- name: "Include example"
ansible.builtin.include_role:
name: example
22 changes: 22 additions & 0 deletions roles/gitlab/molecule/default/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
scenario:
name: default
driver:
name: docker
lint: |
set -e
yamllint .
ansible-lint
platforms:
- name: instance
image: "ghcr.io/pulibrary/pul_containers:jammy_multi"
command: "sleep infinity"
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
privileged: true
pre_build_image: true
provisioner:
name: ansible
log: true
verifier:
name: ansible
20 changes: 20 additions & 0 deletions roles/gitlab/molecule/default/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
- name: Verify
hosts: all
gather_facts: false
tasks:
- name: check ruby package status
package:
name: "{{ item }}"
state: present
check_mode: true
register: pkg_status
loop:
- ruby-switch
- ruby2.6-dev
- ruby2.6

- name: test for ruby packages
assert:
that:
- not pkg_status.changed
55 changes: 55 additions & 0 deletions roles/gitlab/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
# tasks file for roles/gitlab
- name: Gitlab | Install required packages
ansible.builtin.apt:
name:
- curl
- ca-certificates
- tzdata
state: present
update_cache: true

- name: Gitlab | Configure Postfix
# Example with debconf:
ansible.builtin.debconf:
name: postfix
question: postfix/{{ item.question }}
value: "{{ item.value }}"
vtype: "{{ item.vtype }}"
notify: Restart mail service
loop:
# General mail configuration type
- question: main_mailer_type
value: "Satellite system"
vtype: select
# SMTP relay host
- question: relayhost
value: "lib-ponyexpr-prod.princeton.edu"
vtype: string

- name: Gitlab | Install required postfix
ansible.builtin.apt:
name: postfix
autoremove: true
state: present
environment:
DEBIAN_FRONTEND: noninteractive

- name: GitLab | add package repository
ansible.builtin.apt_repository:
repo: deb https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh main
state: present

- name: GitLab | install CE package
ansible.builtin.apt:
name: gitlab-ce
state: present

- name: Copy GitLab configuration file
ansible.builtin.template:
src: gitlab.rb.j2
dest: /etc/gitlab/gitlab.rb
owner: root
group: root
mode: "0600"
notify: reconfigure gitlab
2 changes: 2 additions & 0 deletions roles/gitlab/tests/inventory
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
localhost

5 changes: 5 additions & 0 deletions roles/gitlab/tests/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
- hosts: localhost
remote_user: root
roles:
- roles/gitlab
2 changes: 2 additions & 0 deletions roles/gitlab/vars/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
# vars file for roles/gitlab

0 comments on commit 65099ec

Please sign in to comment.