ansible, simplicity, and the zen of python
TRANSCRIPT
![Page 1: Ansible, Simplicity, and the Zen of Python](https://reader030.vdocuments.mx/reader030/viewer/2022032700/55d2d631bb61eba0578b481b/html5/thumbnails/1.jpg)
Todd Owen
Ansible, Simplicity, and the Zen of Python
![Page 2: Ansible, Simplicity, and the Zen of Python](https://reader030.vdocuments.mx/reader030/viewer/2022032700/55d2d631bb61eba0578b481b/html5/thumbnails/2.jpg)
Koan 1
![Page 3: Ansible, Simplicity, and the Zen of Python](https://reader030.vdocuments.mx/reader030/viewer/2022032700/55d2d631bb61eba0578b481b/html5/thumbnails/3.jpg)
master
agent
agent
MANIFESTSSL
Puppet
![Page 4: Ansible, Simplicity, and the Zen of Python](https://reader030.vdocuments.mx/reader030/viewer/2022032700/55d2d631bb61eba0578b481b/html5/thumbnails/4.jpg)
for host in `cat /etc/temple_hosts` do ssh $host sudo apt-get purge puppet done
Bash
![Page 5: Ansible, Simplicity, and the Zen of Python](https://reader030.vdocuments.mx/reader030/viewer/2022032700/55d2d631bb61eba0578b481b/html5/thumbnails/5.jpg)
————————————————————————————————————————— / 3. Simple is better than complex. \ \ / ————————————————————————————————————————— \ ^__^ \ (oo)\_______ (__)\ )\/\ ||————w | || ||
>>> import this
![Page 6: Ansible, Simplicity, and the Zen of Python](https://reader030.vdocuments.mx/reader030/viewer/2022032700/55d2d631bb61eba0578b481b/html5/thumbnails/6.jpg)
master
agent
agent
MANIFEST SSL
for host in `cat /etc/temple_hosts` do ssh $host sudo apt-get purge puppet done
Push
Pull
SIMPLE
![Page 7: Ansible, Simplicity, and the Zen of Python](https://reader030.vdocuments.mx/reader030/viewer/2022032700/55d2d631bb61eba0578b481b/html5/thumbnails/7.jpg)
What is Ansible?
• IT automation tool!
• à la puppet, chef, CFEngine, salt, etc!
• Growing fast
![Page 8: Ansible, Simplicity, and the Zen of Python](https://reader030.vdocuments.mx/reader030/viewer/2022032700/55d2d631bb61eba0578b481b/html5/thumbnails/8.jpg)
ThoughtWorks Tech Radar
Ansible
![Page 9: Ansible, Simplicity, and the Zen of Python](https://reader030.vdocuments.mx/reader030/viewer/2022032700/55d2d631bb61eba0578b481b/html5/thumbnails/9.jpg)
Ansible is simple
SSHPLAYBOOK ansible
![Page 10: Ansible, Simplicity, and the Zen of Python](https://reader030.vdocuments.mx/reader030/viewer/2022032700/55d2d631bb61eba0578b481b/html5/thumbnails/10.jpg)
Example playbook
--- - hosts: all sudo: yes tasks: - apt: name=puppet state=absent purge=yes
-i /etc/temple_hosts
![Page 11: Ansible, Simplicity, and the Zen of Python](https://reader030.vdocuments.mx/reader030/viewer/2022032700/55d2d631bb61eba0578b481b/html5/thumbnails/11.jpg)
Python is simple
class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } } Java
print("Hello World!") Python
![Page 12: Ansible, Simplicity, and the Zen of Python](https://reader030.vdocuments.mx/reader030/viewer/2022032700/55d2d631bb61eba0578b481b/html5/thumbnails/12.jpg)
————————————————————————————————————————— / 3. Simple is better than complex. \ \ / ————————————————————————————————————————— \ ^__^ \ (oo)\_______ (__)\ )\/\ ||————w | || ||
4. Complex is better than complicated. !!!!!
![Page 13: Ansible, Simplicity, and the Zen of Python](https://reader030.vdocuments.mx/reader030/viewer/2022032700/55d2d631bb61eba0578b481b/html5/thumbnails/13.jpg)
Occam’s Razor
Complex:!
• many elements!
• all necessary!
Complicated:!
• introduces unnecessary elements
![Page 14: Ansible, Simplicity, and the Zen of Python](https://reader030.vdocuments.mx/reader030/viewer/2022032700/55d2d631bb61eba0578b481b/html5/thumbnails/14.jpg)
Ansible Puppet
apt yum
package
apt yum
APT YUM APT YUM
module: provider:
resource type:
Complex Complicated
OS:
![Page 15: Ansible, Simplicity, and the Zen of Python](https://reader030.vdocuments.mx/reader030/viewer/2022032700/55d2d631bb61eba0578b481b/html5/thumbnails/15.jpg)
Python is uncomplicated
• grp (Unix)!
• winreg (Windows)!
• “…don’t cut off access to platform capabilities or properties” (Guido van Rossum)
![Page 16: Ansible, Simplicity, and the Zen of Python](https://reader030.vdocuments.mx/reader030/viewer/2022032700/55d2d631bb61eba0578b481b/html5/thumbnails/16.jpg)
Koan 2
![Page 17: Ansible, Simplicity, and the Zen of Python](https://reader030.vdocuments.mx/reader030/viewer/2022032700/55d2d631bb61eba0578b481b/html5/thumbnails/17.jpg)
hall
tree
door
corridor
room
office
![Page 18: Ansible, Simplicity, and the Zen of Python](https://reader030.vdocuments.mx/reader030/viewer/2022032700/55d2d631bb61eba0578b481b/html5/thumbnails/18.jpg)
templerunner.zip
src/
main/
java/
temple/
Run.java
![Page 19: Ansible, Simplicity, and the Zen of Python](https://reader030.vdocuments.mx/reader030/viewer/2022032700/55d2d631bb61eba0578b481b/html5/thumbnails/19.jpg)
————————————————————————————————————————— / 5. Flat is better than nested. \ \ / ————————————————————————————————————————— \ ^__^ \ (oo)\_______ (__)\ )\/\ ||————w | || ||
![Page 20: Ansible, Simplicity, and the Zen of Python](https://reader030.vdocuments.mx/reader030/viewer/2022032700/55d2d631bb61eba0578b481b/html5/thumbnails/20.jpg)
Ansible: unarchive
Python: zipfile
.NET: System.IO.Compression
![Page 21: Ansible, Simplicity, and the Zen of Python](https://reader030.vdocuments.mx/reader030/viewer/2022032700/55d2d631bb61eba0578b481b/html5/thumbnails/21.jpg)
Namespace
Ansible:
Python: zipfile
.NET: System.IO.Compression
unarchive
ZipFile
ZipArchive
![Page 22: Ansible, Simplicity, and the Zen of Python](https://reader030.vdocuments.mx/reader030/viewer/2022032700/55d2d631bb61eba0578b481b/html5/thumbnails/22.jpg)
————————————————————————————————————————— / 19. Namespaces are one honking great \ \ idea -- let's do more of those! / ————————————————————————————————————————— \ ^__^ \ (oo)\_______ (__)\ )\/\ ||————w | || ||
![Page 23: Ansible, Simplicity, and the Zen of Python](https://reader030.vdocuments.mx/reader030/viewer/2022032700/55d2d631bb61eba0578b481b/html5/thumbnails/23.jpg)
Namespace
Roles: Stouts django
cchurch django
futurice django
![Page 24: Ansible, Simplicity, and the Zen of Python](https://reader030.vdocuments.mx/reader030/viewer/2022032700/55d2d631bb61eba0578b481b/html5/thumbnails/24.jpg)
Koan 3
![Page 25: Ansible, Simplicity, and the Zen of Python](https://reader030.vdocuments.mx/reader030/viewer/2022032700/55d2d631bb61eba0578b481b/html5/thumbnails/25.jpg)
sum_fields --delim="," tally_columns
export IFS="," !!... !
![Page 26: Ansible, Simplicity, and the Zen of Python](https://reader030.vdocuments.mx/reader030/viewer/2022032700/55d2d631bb61eba0578b481b/html5/thumbnails/26.jpg)
————————————————————————————————————————— / 2. Explicit is better than implicit. \ \ / ————————————————————————————————————————— \ ^__^ \ (oo)\_______ (__)\ )\/\ ||————w | || ||
![Page 27: Ansible, Simplicity, and the Zen of Python](https://reader030.vdocuments.mx/reader030/viewer/2022032700/55d2d631bb61eba0578b481b/html5/thumbnails/27.jpg)
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"
![Page 28: Ansible, Simplicity, and the Zen of Python](https://reader030.vdocuments.mx/reader030/viewer/2022032700/55d2d631bb61eba0578b481b/html5/thumbnails/28.jpg)
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"
![Page 29: Ansible, Simplicity, and the Zen of Python](https://reader030.vdocuments.mx/reader030/viewer/2022032700/55d2d631bb61eba0578b481b/html5/thumbnails/29.jpg)
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}}"
![Page 30: Ansible, Simplicity, and the Zen of Python](https://reader030.vdocuments.mx/reader030/viewer/2022032700/55d2d631bb61eba0578b481b/html5/thumbnails/30.jpg)
Ansible and Python
Similar design philosophy!
• Simple!
• Consistent!
• Easy to learn
![Page 31: Ansible, Simplicity, and the Zen of Python](https://reader030.vdocuments.mx/reader030/viewer/2022032700/55d2d631bb61eba0578b481b/html5/thumbnails/31.jpg)
Ansible vision
Michael DeHaan, BDFL!
“radically simple”!
“easiest config management system to use, ever”!
— README v0.0.1
![Page 32: Ansible, Simplicity, and the Zen of Python](https://reader030.vdocuments.mx/reader030/viewer/2022032700/55d2d631bb61eba0578b481b/html5/thumbnails/32.jpg)
simple less!features
simple consistent!mental model
≠
=
![Page 33: Ansible, Simplicity, and the Zen of Python](https://reader030.vdocuments.mx/reader030/viewer/2022032700/55d2d631bb61eba0578b481b/html5/thumbnails/33.jpg)
————————————————————————————————————————— / 8. Special cases aren't special \ \ enough to break the rules. / ————————————————————————————————————————— \ ^__^ \ (oo)\_______ (__)\ )\/\ ||————w | || ||
![Page 34: Ansible, Simplicity, and the Zen of Python](https://reader030.vdocuments.mx/reader030/viewer/2022032700/55d2d631bb61eba0578b481b/html5/thumbnails/34.jpg)
–Michael DeHaan
“We’re simplifiers. We’re seeking a whole new technical aesthetic where much of the
software industry has been adrift.”
![Page 35: Ansible, Simplicity, and the Zen of Python](https://reader030.vdocuments.mx/reader030/viewer/2022032700/55d2d631bb61eba0578b481b/html5/thumbnails/35.jpg)
————————————————————————————————————————— / 1. Beautiful is better than ugly. \ \ / ————————————————————————————————————————— \ ^__^ \ (oo)\_______ (__)\ )\/\ ||————w | || ||
![Page 36: Ansible, Simplicity, and the Zen of Python](https://reader030.vdocuments.mx/reader030/viewer/2022032700/55d2d631bb61eba0578b481b/html5/thumbnails/36.jpg)
Beautiful!Python
simplicity!minimalism!pragmatism
=
Analytics & Information Team, Commonwealth Bank
WE’RE HIRING!
![Page 37: Ansible, Simplicity, and the Zen of Python](https://reader030.vdocuments.mx/reader030/viewer/2022032700/55d2d631bb61eba0578b481b/html5/thumbnails/37.jpg)
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.!