2. Interesting stuff in 2.0
• Revamped core, makes many fixes and new features possible
• More information and better error handling (consequence of core revamp)
• Improved inheritance model
• Strategies
• Blocks
• Dynamic includes
• meta: refresh_inventory
• delegate_facts
• Plugins … sooo many plugins ….
_______________________________________________
/ http://docs.ansible.com/ansible/porting_guide_2.0.html
or read CHANGELOG for more details /
-----------------------------------------------
^__^
(oo)_______
(__) )/
||----w |
|| ||
3. More information
#> ansible-playbook -vv play.yml
Using /etc/ansible/ansible.cfg as config file
PLAYBOOK: play.yml *************************************************************
1 plays in play.yml
TASK [wait_for] ****************************************************************
task path: /home/bcoca/work/testing/play.yml:5
ok: [localhost] => (item=1) => {"changed": false, "elapsed": 1, "failed": false, "failed_when_result": false,
"item": 1, "path": null, "port": null, "search_regex": null, "state": "started"}
failed: [localhost] => (item=2) => {"changed": false, "elapsed": 2, "failed": true, "failed_when_result": true,
"item": 2, "path": null, "port": null, "search_regex": null, "state": "started"}
skipping: [localhost] => (item=3) => {"changed": false, "item": 3, "skip_reason": "Conditional check failed",
"skipped": true}
NO MORE HOSTS LEFT *************************************************************
PLAY RECAP *********************************************************************
localhost : ok=0 changed=0 unreachable=0 failed=1
4. - command: /do/some/stuff
when: a == b
when: c == d
PREVIOUSLY:
a == b is ignored
only c == d is considered
NO ERRORS OR WARNINGS
Better error handling
NOW:
ERROR! Syntax Error while loading YAML.
The error appears to have been in '/home/bcoca/work/test/play.yml': line 6, column 6, but
may be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
- command: do some stuff
when: a == b
^ here
5. Better error handling
- command: /do/stuff
wen: a == b
PREVIOUSLY:
a == b is ignored
command is always executed
NO ERRORS OR WARNINGS
NOW:
ERROR! Syntax Error while loading YAML.
The error appears to have been in '/home/bcoca/work/test/play.yml': line 6, column 6, but
may be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
- command: do some stuff
wen: a == b
^ here
6. Better error handling
- hosts: servers
tasks:
command: /do/stuff
PREVIOUSLY:
command is ignored
NO ERRORS OR WARNINGS
NOW:
ERROR! Syntax Error while loading YAML.
The error appears to have been in '/home/bcoca/testing/ansible/play.yml': line 3, column 6,
but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
command: /do/stuff
^ here
7. No Inheritance
- hosts: appservers
vars:
stuff: “todays_info_{{lookup(‘pipe’, ‘date +%s’)}}”
become: yes
tasks:
- get_url: url= www.example.com/{{stuff}}.rpm dest=/temp/
ignore_errors: True
become: no
- yum: package=/temp/{{stuff}}.rpm state=present
ignore_errors: True
become: no
- service: name=stuff_service state=restarted
ignore_errors: True
become: no
10. Strategy: linear (as usual)
10 servers 5 forks:
- task 1: 5 first servers
- task 1: 5 next servers
- task 2: 5 first servers
- task 2: 5 next servers
- task 3: 5 first servers
- task 3: 5 next servers
_________________________________
/ Each batch ends as fast as the
slowest server in the group. /
---------------------------------
__
UooU.'@@@@@@`.
__/(@@@@@@@@@@)
(@@@@@@@@)
`YY~~~~YY'
|| ||
11. Strategy: linear (serial 5)
10 servers 5 serial 5 forks:
_____________________________
/ Each batch is now per play,
instead of per task. /
-----------------------------
oO)-. .-(Oo
/__ _ /_ __
( | ()~() | )/ /
__| | (-___-) | /|__/
' '--' ==`-'== '--' '
- task 1: 5 first servers
- task 2: 5 first servers
- task 3: 5 first servers
- task 1: 5 next servers
- task 2: 5 next servers
- task 3: 5 next servers
12. Stragegy: free
10 servers 5 forks:
- task1: server1, server2, server3
- task2: server1, server2 && task1: server4, server5
- task3: server1 && task2: server3
- task2: server4 && task1: server6
- task1: server7 && task2: server5, server2 && task3: server3
- task2: server6, server7 && task3: server4, server5 && task1: server8
- task3: server6, server7, server2 && task1: server9, server10 ...
_____________________________________
/ Each server finishes play as
| fast as it can, when it is done | /_)o<
a new server can start. / |
------------------------------------- | O . O|
_____/
13. Strategy: free
- name: Heartbleed update
hosts: all
strategy: free
tasks:
- apt: name=openssh state=latest update_cache=yes
_________________________________________
/ Now you update hosts as fast as they
can, no need to wait for a ‘slow host’. /
-----------------------------------------
/
( )
.( o ).
14. Blocks: Error handling (Before)
- command: /do/stuff
register: myvar
ignore_errors: True
- command: /do/more/stuff
register: myvar2
ignore_errors: True
…
- command: /recover
when: myvar|failed or myvar2|failed or ...
____________________________________
/ each command must ignore errors
| and register a variable, then use |
complex conditionals to capture /
------------------------------------
___
{~._.~}
( Y )
()~*~()
(_)-(_)
24. Moar!
• easier shipped callback activation: whitelist (skippy, profile_tasks)
• many new modules/tasks (iptables, package, solaris_zone, puppet ... 200+)
• more lookups and filters (hashi_vault, credstash,combine)
• new plugin class tests: jinja2 tests, making map/select filters more powerful
• winrm improvements
• docker connection plugin
• vault improvements: stdin/stdout, multiple files, …
• inventory scripts: now installed with system packages, new, improved, etc
• lots more, read CHANGELOG and porting guides
• Can autodocument classes http://docs.ansible.com/ansible/playbooks_directives.html
25. Next: The road to 2.1
• Back to frequent releases (3-4 months)
• Roadmaps
• Windows out of beta
• Increased Networking support
• Improving community process: proposals
• Bug fixes … always more bug fixes …
• There is more … but I’m out of time … any questions?
________________________
/ Proposals and Roadmaps
are in the repo /
------------------------
(__)
(/)
/-------/
/ | 666 ||
* ||----||
~~ ~~