This guide will help you set up a virtual machine (VM) with Ansible, configure domain and subdomains, and deploy necessary configurations using an Ansible playbook.
- VM with Ansible Installed
- Domain and Subdomains
- SSH Key
In your Ansible project directory, create or edit the vault.yml
file to include your domain and subdomains:
jenkins_domain: jenkins.example.com
traefik_domain: traefik.example.com
checkmk_domain: checkmk.example.com
authentik_domain: authentik.example.com
Copy your SSH public key to the target server:
ssh-copy-id -i ~/.ssh/your_key_name.pub user@target-server-ip
Replace user
with your target server's username and target-server-ip
with its IP address.
Run the playbook with the following command:
ansible-playbook backup-server.yml --ask-vault-pass
This command will prompt you for the vault password. You can find the password in your documentation at deployment/ansible.md
.
-
Gitlab plugin: To install the GitLab plugin in Jenkins, navigate to the Jenkins dashboard and click on "Manage Jenkins". Then, select "Manage Plugins." In the "Plugin Manager" page, go to the "Available" tab and search for "GitLab". Jenkins will then download and install the plugin.
-
Security settings: To ensure secure communication and configuration in Jenkins, navigate to the Jenkins dashboard, click on "Manage Jenkins", and select "Configure Global Security". In the security settings, enable the proxy setting (CSRF Protection) to enhance security measures.
-
User settings: To configure an easier password, navigate to the Jenkins dashboard. Click on your username, then go to the admin section. In the configuration settings, change the default password. Save the configuration, and you will need to log in again with the new password.
-
Gitlab connection: To set up a connection between Jenkins and GitLab, go to your GitLab account and create a personal access token with the necessary scopes for Jenkins integration. Return to the Jenkins dashboard and click on "Manage Jenkins," then select "Configure System." In the "GitLab" section, add the GitLab server details and the personal access token created in GitLab.
-
Create a CI/CD Pipeline: To configure a CI/CD pipeline for your project, navigate to your Jenkins dashboard, click on "New Item," and select "Pipeline." Configure the pipeline by specifying the GitLab repository and defining the stages and steps for your CI/CD process.
- Necessary steps in web platform:
- Go to dashboard, select the correct pipeline that you just made and click configuration.
- Go to the section pipeline and choose "pipeline script from SCM".
- Write the correct repository URL (choose the correct branch) and add new credentials.
- Click safe.
-
Necessary steps in destination container:
docker exec -it [containerID] /bin/bash
ssh-keygen
-
Necessary steps in Jenkins container:
ssh-keygen
cat id_rsa.pub
and copy the key in the destination container in 'authorized_keys'- You have do do a manual ssh connection:
ssh root@[ip]
- Go to dashboard, select "Manage Jenkins". Go to credentials and ad a new credential (secret file). Upload the
vault.yml
(ID = VaultFile) and upload the.env
file (ID = EnvFile). - In the jenkinsfile:
- Go to dashboard, select "Manage Jenkins". Go to credentials and copy the correct ID.
git credentialsId: '[correct ID]', branch: 'dev', url: 'https://gitlab.apstudent.be/nox/znz-infra.git'