Todd Owen
Ansible, Simplicity,
and the Zen of Python
Koan 1
master
agent
agent
MANIFEST
SSL
Puppet
for host in `cat /etc/temple_hosts`
do
ssh $host sudo apt-get purge puppet
done
Bash
—————————————————————————————————————————
/ 3. Simple is better than complex. 
 /
—————————————————————————————————————————
 ^__^
 (oo)_______
(__) )/
||————w |
|| ||
>>> import this
master
agent
agent
MANIFEST
SSL
for host in `cat /etc/temple_hosts`
do
ssh $host sudo apt-get purge puppet
done
Push
Pull
SIMPLE
What is Ansible?
•IT automation tool!
•à la puppet, chef, CFEngine, salt, etc!
•Growing fast
ThoughtWorks Tech Radar
Ansible
Ansible is simple
SSH
PLAYBOOK
ansible
Example playbook
---
- hosts: all
sudo: yes
tasks:
- apt: name=puppet state=absent purge=yes
-i /etc/temple_hosts
Python is simple
class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
Java
print("Hello World!")
Python
—————————————————————————————————————————
/ 3. Simple is better than complex. 
 /
—————————————————————————————————————————
 ^__^
 (oo)_______
(__) )/
||————w |
|| ||
4. Complex is better than complicated.
!
!
!
!
!
Occam’s Razor
Complex:!
• many elements!
• all necessary!
Complicated:!
• introduces unnecessary elements
Ansible Puppet
apt yum
package
apt yum
APT YUM APT YUM
module: provider:
resource type:
Complex Complicated
OS:
Python is uncomplicated
• grp (Unix)!
• winreg (Windows)!
• “…don’t cut off access to platform capabilities or
properties” (Guido van Rossum)
Koan 2
hall
tree
door
corridor
room
office
templerunner.zip
src/
main/
java/
temple/
Run.java
—————————————————————————————————————————
/ 5. Flat is better than nested. 
 /
—————————————————————————————————————————
 ^__^
 (oo)_______
(__) )/
||————w |
|| ||
Ansible: unarchive
Python: zipfile
.NET: System.IO.Compression
Namespace
Ansible:
Python: zipfile
.NET: System.IO.Compression
unarchive
ZipFile
ZipArchive
—————————————————————————————————————————
/ 19. Namespaces are one honking great 
 idea -- let's do more of those! /
—————————————————————————————————————————
 ^__^
 (oo)_______
(__) )/
||————w |
|| ||
Namespace
Roles: Stouts django
cchurch django
futurice django
Koan 3
sum_fields --delim="," tally_columns
export IFS=","
!
!
...
!
—————————————————————————————————————————
/ 2. Explicit is better than implicit. 
 /
—————————————————————————————————————————
 ^__^
 (oo)_______
(__) )/
||————w |
|| ||
Explicit module result
tasks:
- name: Verify Python 3.x is the default
command: /usr/bin/python --version
register: pyver
failed_when: "'Python 3' not in pyver.stderr"
Magic variable?
tasks:
- name: Verify Python 3 is the default
command: /usr/bin/python --version
register: pyver
failed_when: "'Python 3' not in res.stderr"
Magic variable?
tasks:
- name: Verify Python 3 is the default
command: /usr/bin/python --version
register: pyver
failed_when: "'Python 3' not in res.stderr"
!
- copy: dest=~/py.ver content="{{res.stderr}}"
Ansible and Python
Similar design philosophy!
•Simple!
•Consistent!
•Easy to learn
Ansible vision
Michael DeHaan, BDFL!
“radically simple”!
“easiest config management
system to use, ever”!
— README v0.0.1
simple
less!
features
simple
consistent!
mental model
≠
=
—————————————————————————————————————————
/ 8. Special cases aren't special 
 enough to break the rules. /
—————————————————————————————————————————
 ^__^
 (oo)_______
(__) )/
||————w |
|| ||
–Michael DeHaan
“We’re simplifiers. We’re seeking a whole
new technical aesthetic where much of the
software industry has been adrift.”
—————————————————————————————————————————
/ 1. Beautiful is better than ugly. 
 /
—————————————————————————————————————————
 ^__^
 (oo)_______
(__) )/
||————w |
|| ||
Beautiful!
Python
simplicity!
minimalism!
pragmatism
=
todd.owen@cba.com.au!
!
Analytics & Information Team, Commonwealth Bank
WE’RE HIRING!
Image Credits
!
ThoughtWorks Technology Radar! ! Copyright ThoughtWorks!
Ansible Galaxy Logo!! ! ! ! ! Copyright Ansible, Inc.!
Github Avatar!! ! ! ! ! ! ! Copyright Michael DeHaan!
All other images! ! ! ! ! ! ! Public domain
Copyright
!
This work by Todd Owen is licensed under a Creative
Commons Attribution 4.0 International License.!

Ansible, Simplicity, and the Zen of Python