This project aims to deploy a GitLab server in an automated manner using Ansible. The process involves setting up a virtual machine for GitLab and automating its installation and configuration, as well as setting up a PostgreSQL database.
Before starting, ensure that you have:
- A virtual machine (VM) set up with a Linux distribution (Ubuntu Server, Debian, or Rocky Linux).
- Ansible installed on the control/master machine.
- SSH access configured between the control machine and the target VMs.
- Necessary ports open on the firewall (e.g., port 80 for HTTP and 22 for SSH).
This project deploys:
- One VM to host the GitLab server.
- An optional VM for a PostgreSQL database (depending on your requirements).
-
Configure Virtual Machines:
- Create two VMs (one for GitLab, one for PostgreSQL if needed).
- Set up SSH access between your control machine and the VMs.
-
Install Ansible:
- Install Ansible on the control machine via a package manager (e.g.,
sudo apt install ansible).
- Install Ansible on the control machine via a package manager (e.g.,
-
Develop Ansible Roles:
commonRole: Sets up basic dependencies (updates packages, installs essential tools, etc.).bddRole: Deploys PostgreSQL and configures the required databases (all,dev,stage,prod).gitlabRole: Installs and configures GitLab using Ansible variables.
Your Ansible project should follow this structure:
ansible-project/
├── deploy.yml
├── inventory.yml
├── roles/
│ ├── common/
│ │ ├── tasks/
│ │ │ └── main.yml
│ │ ├── vars/
│ │ │ └── main.yml
│ │ └── handlers/
│ │ └── main.yml
│ ├── gitlab/
│ │ ├── tasks/
│ │ │ └── main.yml
│ │ ├── vars/
│ │ │ └── main.yml
│ │ └── handlers/
│ │ └── main.yml
│ └── bdd/
│ ├── tasks/
│ │ └── main.yml
│ ├── vars/
│ │ └── main.yml
│ └── handlers/
│ └── main.yml
test gitlab:
netstat -pauntansible-playbook -i inventory.yml deploy.ymlIf you want to clean, the host use the script refresh.sh.


