So you can use Ansible for environmental provisioning and
application deployment in continuous integration and continuous
delivery process using the Jenkins pipeline.
Shell scripts are commonly used to provision environments and deploy
apps during the pipeline flow. Although this can work, maintaining
it can be extremely difficult. Reusing scripts is cumbersome in the
long run, and I would recommend better consistency for your
production environments.
So the purpose of using Ansible in the pipeline flow is to reuse roles and
playbooks for provisioning, leaving Jenkins only as a process orchestrator
instead of a shell script executer. So Jenkins can be connected to the Tower to
launch job templates for automated testing. Jenkins will call the Ansible Tower
API to launch a specific job template. That invokes an Ansible playbook to
provision your chosen environment,
deploy, and configure the appropriate software stack, and even the
correct application version, and carry out different tests.
The really big benefit is that Jenkins never touches the machines,
all of which is delegated to Ansible Tower to carry out the
heavy work to provision the machines.
So, this can work well in Tower clustering environments, as Jenkins
doesn't even know where the application is and what needs to be done,
or even aware of any SSH keying. Any administrative access is key to
audit and watching for actions.
A good audit trail is an important feature that is hard to
implement with the manual approach. A version Source Control will
leave an audit trail, describing when and why you change the rules
that automate your infrastructure.
The Ansible Tower audit trail is carried out via the built‑in activity
stream support, that logs all changes within Tower.
So it is recommended to centrally collect log and audit
instead of reviewing it on the local systems.
Ansible Tower can be integrated with several IDS and logging auditing systems
and has built‑in logging integrations for the ELK stack,
Splunk, Sumo Logic, and Loggly. For example, with Splunk, the Ansible Tower
Splunk login integration uses the Splunk HTTP collector.
This allows you to aggregate all the logs and view them in
a central place with custom dashboards.
As already mentioned,
we can use Prometheus to scrape metrics for Ansible Tower and the OS it is
running on. Prometheus uses scalable pull approach escaping metrics from HTTP
endpoints. Prometheus can scrape metrics in two ways,
node exporters and client libraries.
So within an Ansible Tower environment, this is done with a node
exporter instead of the Prometheus Client library.
Once Prometheus gathers the metrics, they can be
viewed in dashboards with Grafana.