際際滷

際際滷Share a Scribd company logo
Testing Ansible with Ansible
Allan Denot
 1 year experience with Ansible
 2 years experience with AWS
 DevOps Engineer at cammy.com (previously Suncorp)
 Co-founder of spikenode.com
@denot allandenot.com
Allan Denot @denot allandenot.com
 Brazilian
 4 years in Australia
Why we need testing?
TEAMBTEAMA
The Problem
Configuring
servers!
Deploying
app!
The ProblemTEAMB
App is not working. Was
the server configured?
TEAMA
Yes... Probably...
Oh wait, our
playbook failed
Then why apache is
not installed?
Solution
Configuring
servers!
Ok, let me
check.
TEAMBTEAMA
All good!
Deploying app!
s
e
r
v
e
r
SolutionTEAMB
asserts the state of the servers before deploying and
only deploys if passes
Useful when different teams are in
charged of different layers of
configuration.
operational system
web server
database
application
Testing with custom module
Example playbook:
- name: Test Setup Webservers
hosts: all
tasks:
- assert_file: name=/apps should_be=directory
- assert_owner: name=/apps should_be=appuser
- assert_tcp: name=localhost:80 should_be=open with_timeout=3
Custom module
https://github.com/adenot/ansible-testing
Testing permissions:
- assert_mode: name=/tmp/testfile should_be=0755
- assert_owner: name=/tmp/testfile should_be=adenot
- assert_group: name=/tmp/testfile should_be=users
Custom module
https://github.com/adenot/ansible-testing
Testing files/directories:
- assert_group: name=/tmp/testfile should_be=users
- assert_file: name=/tmp/testfile should_be=file
- assert_file: name=/tmp/testdir should_be=directory
- assert_content: name=/tmp/testfile should_match="example.*string"
Custom module
https://github.com/adenot/ansible-testing
Testing processes/ports:
- assert_process: name=/sbin/agetty should_be=running with_args='38400'
- assert_tcp: name=localhost:9001 should_be=open with_timeout=3
- assert_command: name='netstat -nl|grep ":9001"' should_be=successful
Demo
Questions?
Links
github.com/adenot/ansible-testing
allandenot.com
spikenode.com

More Related Content

Ansible testing