Skip to content

parvvareshInfrastructure/Ansible-lab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ansible Multi-Server Deployment: GitLab, GitLab Runner, PostgreSQL

This repository provides an Ansible-based solution to set up the following services across three separate servers:

  • GitLab: Self-hosted Git repository management (Server 1)
  • GitLab Runner: For CI/CD jobs (Server 2)
  • PostgreSQL: Dedicated database server (Server 3)

Inventory Example

Update the inventory.ini file with your servers’ addresses:

[gitlab]
gitlab.example.com ansible_host=192.168.10.11

[gitlab_runner]
runner.example.com ansible_host=192.168.10.12

[postgresql]
db.example.com ansible_host=192.168.10.13

How It Works

  • Each service is installed and configured only on its designated host.
  • All tasks are organized in Ansible roles for better maintainability.
  • The project uses a single playbook, playbook.yml, to orchestrate the installation.

Usage

  1. Clone the repository

    git clone https://github.com/parvvareshInfrastructure/Ansible-lab
    cd ansible-lab
  2. Edit the inventory

    • Open inventory.ini and set your server hostnames or IP addresses.
  3. (Optional) Adjust variables

    • If you want to set custom values (e.g., database passwords, external URLs), edit the role defaults or provide extra variables.
  4. Run the playbook

    ansible-playbook -i inventory.ini playbook.yml
    • Make sure you have SSH access and become (sudo) privileges on all target servers.

Roles Overview

GitLab

  • Installs GitLab CE
  • Configures and starts the GitLab service

GitLab Runner

  • Installs GitLab Runner
  • Ensures the Runner service is enabled and running
  • Optionally registers the runner if registration token and GitLab URL are provided

PostgreSQL

  • Installs PostgreSQL server
  • Starts and enables the PostgreSQL service
  • Creates a user and a database for GitLab (you can customize these in the role)

Customization

  • Database configuration: You may need to update GitLab’s database settings (in /etc/gitlab/gitlab.rb) to point to the external PostgreSQL host. This can be done using an Ansible lineinfile or template task.

  • Runner registration: If you want to automate runner registration, supply the registration_token and gitlab_url as variables. Otherwise, register manually using the output from your GitLab instance.


Requirements

  • Ansible 2.9+
  • Target servers running Ubuntu (roles can be adapted for other distributions)
  • Sudo privileges on all target servers

Notes

  • This setup is designed for test or internal deployments. For production, review each role for hardening, TLS configuration, and secure secret handling.
  • Adjust firewalls and security groups as needed so services can communicate.

Troubleshooting

  • Check Ansible logs for errors during playbook execution.

  • Ensure all target servers are reachable and have Python installed.

  • After deployment, access:

    • GitLab: http://gitlab.example.com
    • GitLab Runner: Managed by the GitLab UI
    • PostgreSQL: On db.example.com (customize users/passwords as needed)

License

MIT License. Use at your own risk.

About

Ansible Multi-Server Deployment

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published