Chapter 22. CI/CD and Ansible

Roles are the basic components used to compose infrastructure as code (IaC) with Ansible. Treating systems administration as software engineering and applying software development practices to IaC is one of the foundations of Agile operations. You can decrease errors, increase productivity, and achieve more successful changes and less downtime by staging these changes in software environments and automating the verification of changes. By assessing code quality and automated tests in isolated environments, you can eliminate errors before their blast radius gets too large.

This chapter describes how to set up the core of a continuous integration and continuous delivery (CI/CD) environment for software teams, consisting of a central repository proxy for binaries and libraries, a source control system, a code quality tool, and a continuous integration server. The example code provisions four virtual machines with Sonatype Nexus3, Gitea, SonarQube, and Jenkins. Jenkins can use Ansible ad hoc commands and Ansible playbooks via the Ansible plug-in. The Ansible Tower plug-in for Jenkins can access Ansible Automation Platform (still affectionally known as Tower) to request various things like starting job templates.

Continuous Integration

In 2006, Martin Fowler published an influential article on Continuous Integration, a successful practice in software development, describing it as follows:

a software development practice where members of a team integrate ...

Get Ansible: Up and Running, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.