Skip to content

Instantly share code, notes, and snippets.

@gridhead
Last active May 16, 2021 15:32
Show Gist options
  • Save gridhead/8fb8a4a146707c0d0036324ab23c3bc3 to your computer and use it in GitHub Desktop.
Save gridhead/8fb8a4a146707c0d0036324ab23c3bc3 to your computer and use it in GitHub Desktop.
Setup Ravermeister/Gitlab Container on Docker Host
[web]
server1 ansible_host=192.168.0.165
server1 ansible_ssh_user=ubuntu
server1 ansible_ssh_pass=<your-ssh-password>
server1 ansible_sudo_pass=<your-sudo-password>

Setup Ravermeister/Gitlab Container on Docker Host

  1. Download the inventory.ini and setup-ravermeister-gitlab-on-docker-host.yml file in the same directory.
  2. Make changes to the inventory.ini file to change the hostname, username, passwords (for SSH and Sudo).
  3. Make changes in the setup-ravermeister-gitlab-on-docker-host.yml file to change the following variables.
    1. Volume mapping on the host device for GitLab configuration files.
    2. Volume mapping on the host device for GitLab log files.
    3. Volume mapping on the host device for GitLab Data files.
    4. Published port mapping on the host device for HTTPS.
    5. Published port mapping on the host device for HTTP.
    6. Published port mapping on the host device for SSH access.
    7. Restart policy for the container.
  4. Once all of the above changes are made, save the playbook and execute it using the following command.
    ansible-playbook -i inventory.ini setup-ravermeister-gitlab-on-docker-host.yml -vvv
    
- name: "Setup Ravermeister/Gitlab Container on Docker Host"
hosts: server1
remote_user: ubuntu
become: yes
become_method: sudo
become_user: root
vars:
confdrct: "/home/ubuntu/data/gitlab/config"
logsdrct: "/home/ubuntu/data/gitlab/logs"
datadrct: "/home/ubuntu/data/gitlab/data"
hosttlsp: "4343"
hosthttp: "8800"
hostsshp: "2222"
restplcy: "unless-stopped"
tasks:
- name: "STEP 1 - Install python3-docker on the remote machine first"
apt:
update_cache: "yes"
name: "python3-docker"
state: "latest"
- name: "STEP 2 - Pull the Gitlab image from Ravermeister's namespace"
community.docker.docker_image:
name: "ravermeister/gitlab:latest"
source: "pull"
- name: "STEP 3 - Start the Gitlab container with the mentioned parameters"
docker_container:
name: "gitlab"
image: "ravermeister/gitlab"
volumes:
- "{{ confdrct }}:/etc/gitlab"
- "{{ logsdrct }}:/var/log/gitlab"
- "{{ datadrct }}:/var/opt/gitlab"
ports:
- "{{ hosttlsp }}:443"
- "{{ hosthttp }}:80"
- "{{ hostsshp }}:22"
restart_policy: "{{ restplcy }}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment