Skip to content

Instantly share code, notes, and snippets.

@platu
Created March 24, 2024 18:17
Show Gist options
  • Save platu/db43d801af6ee63da7e704cbf309f8a4 to your computer and use it in GitHub Desktop.
Save platu/db43d801af6ee63da7e704cbf309f8a4 to your computer and use it in GitHub Desktop.
IaC Lab 3 GitLab pipeline
variables:
PIP_CACHE_DIR: $CI_PROJECT_DIR/.cache/pip
cache:
paths:
- .cache/pip
- ansible/
stages:
- Build
- Ping
- Prepare
- CopyRun
- Configure
# This job creates a virtual environment and installs the required packages
# - ansible latest version
# - ansible-lint latest version which is compatible with Python >= 3.12
# - ansible-pylibssh as defined in ansible.cfg
Build venv:
stage: Build
script:
- python3 -m venv ansible && source ./ansible/bin/activate && pip3 install -r requirements.txt
Ping hypervisors:
stage: Ping
needs:
- Build venv
script:
- source ./ansible/bin/activate
- ansible hypervisors -m ping --extra-vars @$HOME/iac_lab03_passwd.yml
Prepare hypervisors:
stage: Prepare
needs:
- Ping hypervisors
script:
- source ./ansible/bin/activate
- ansible-playbook prepare.yml --extra-vars @$HOME/iac_lab03_passwd.yml
Startup routers:
stage: CopyRun
artifacts:
paths:
- inventory/
needs:
- Prepare hypervisors
script:
- source ./ansible/bin/activate
- ansible-playbook copy_run.yml --extra-vars @$HOME/iac_lab03_passwd.yml
Configure routers:
stage: Configure
artifacts:
paths:
- inventory/
needs:
- Startup routers
script:
- source ./ansible/bin/activate
- ansible-playbook routers_config.yml --extra-vars @$HOME/iac_lab03_passwd.yml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment