Ansible, Idempotency,
and Jenkins
Tyler Turk
DevOps Engineer - WP Engine
Brief Introduction on Me
DevOps Engineer at WP Engine
Passionate Ansible Advocate
Loves python and automation
Purpose of this talk?
Empower YOU to:
Use ansible and vagrants
Understand importance of idempotency
Test for idempotent playbooks
What is Ansible?The TL;DR Version
What does idempotency
mean?Why is this important? Why do we care?
What is jenkins?
Job scheduler
Job monitor
Job executor
Awesome
What is Jenkins not?
Want to follow along?
Vagrant:
https://github.com/tylerturk/jenkins_ansible_id
empotent_test_vagrant
Playbooks:
https://github.com/tylerturk/jenkins_ansible_id
empotent_test
Issues Faced
docker_image module is deprecated
SSH on Docker is considered evil
(https://jpetazzo.github.io/2014/06/23/docker-ssh-considered-evil/)
wait_for module just waits for TCP
connectivity
(http://docs.ansible.com/wait_for_module.html)
How are we doing this?
Custom python script
Ansible python API
Validating returned data
What’s under the covers?Vagrant provisioned with jenkins and docker
Vagrant builds a docker image that has
ansible
Jenkins provisions docker container with
ansible
Custom python script runs playbook a second
time
Returned results are then validated
Idempotent vs Not
Idempotent
Uses correct ansible
module
Job successfully builds
Profit!
Touches a file
Job fails miserably
Profit!
How can we make this
better?
Identify file and line number of non-
idempotent task
Use with docker and SSH
Improve callback to not write local file
Move traceback to more visible