How to use GitLab and Ansible to create infrastructure as code

Click for: original source

Sara Kassabian and Brad Downey wrote this piece for exploring GitLab CI and how this powerful tool can be used for a number of things, including infrastructure as code. GitLab is tool agnostic, but they use Ansible in this demonstration because it’s a language commonly used by developers for infrastructure as code.

What’s particularly cool about GitLab CI is that the code from the Ansible playbook can be edited and shipped without ever having to install any dependencies locally. The demo project, which calls for an update to the SNMP strings on all devices monthly per GitLab security policy, can be done entirely on

The article then guides through the Ansible playbook, including:

  • Gather router facts
  • Display version
  • Display serial number
  • Configure SNMP

Committing the changes will automatically kick off a GitLab CI pipeline. GitLab CI pipelines are a string of sequential tasks that execute everything you need to test and implement your Ansible code. GitLab CI is configured with a single simple YAML file that lives in the repository, named .gitlab-ci.yml. The tutorial video and repository with the code provided. Great!

[Read More]

Tags ansible cicd devops