testing ansible with jenkins and docker
TRANSCRIPT
• “An extensible open source continuous integration server”
• Lets us run stuff
• Plugins lets you do extra stuff
Create our First Jenkins Project
• Create a freestyle project called “Build Docker Image”
• Use custom workspace (under Advanced). I set my workspace to build_docker_image.
• Configure the source repository (https://github.com/shr3kst3r/ansible-jenkins-example.git)
Docker Plugins
• “Docker plugin”
• https://wiki.jenkins-ci.org/display/JENKINS/Docker+Plugin
• “SSH plugin”
• https://wiki.jenkins-ci.org/display/JENKINS/SSH+plugin
Create our Second Jenkins Project
• Create a freestyle project called “Project Test Ansible with Docker”
• Use custom workspace (under Advanced). I set my workspace to docker_ansible.
• Configure the source repository (https://github.com/shr3kst3r/ansible-jenkins-example.git)
test_it• Lint Ansible code using ansible-lint
(https://github.com/willthames/ansible-lint)
• Run the Ansible playbook
• Verify environment using Serverspec (http://serverspec.org/)
• Source: https://github.com/shr3kst3r/ansible-jenkins-example/blob/master/test_it
Test Container
• I can actually get access to the running container
• Just delete the “Post-build Action”
• Then run the build
Notes
• Similar two the first way, but no Jenkins plugins.
• Derived from the book “The Docker Book” by James Turnbull
Testing on my Mac
• http://boot2docker.io/
• docker build -t jenkins-ansible .
• docker run -v "/Users/dennis/git/ansible-jenkins-example:/build:rw" jenkins-ansible /bin/bash -c 'cd /build && ./test_it’
• docker rm $(docker ps -a -q) # delete
Benefits
• Super fast start times. Do not have to spin up a server.
• Allows for a very quick test lifecycle (22 seconds total time for this simple example)
• Reproducible and Consistent
Ansible and Docker
• Some General Info (interesting video): http://www.ansible.com/docker
• Docker Module: http://docs.ansible.com/docker_module.html
Odds and Ends
• https://github.com/shr3kst3r/ansible-jenkins-example
• You can reach me at [email protected] or @shr3kst3r on the twitters