Tuesday, 22 March 2016
Ansible 2.0 New Features
big software refactoring - previous rapid growth/technical debt, bolted on features like roles not implemented perfectly. lots of code cleanup and make it easier to add ew features going forward..
added blocks - try/except/finally c.f. python; allows you to try things, catch errors falls through to finally.
blocks allow you to group related tasks together, dont need to use tags
- name: stuff 1
can have nested blocks - too many can be overly complex to debug (e.g. could do for multiple OS)
blocks allow subset of variables only set for tasks within that block - local scope
improved error messages, shows line/file/col of task that failed
new option any_errors_fatal: true (if any host fails in block then all hosts go to rescue section - all or nothing deployment) (from 2.0.1)
execution strategy plugins - linear (traditional, wait for all hosts to complete task before moving on to 2nd task etc) or free - each host runs all tasks asap without waiting for others to catch up.
now have dyn-amic includes
improved variable management - variable precedence more consistent
200+ new modules - e.g. ec2,openstack,windows(beta),docker
new inventory scripts
more OO oriented/inheritance etc - more of an internals feature
what might break in V2? should be 100% backwards compatible, most possible issues due to variable precedence and dynamic includes, stricter with yaml now.
Bash best practices A few hints on bash best practice: * use #!/usr/bin/env bash .. this is more portable but you cant rely on a spe...