- Ansible 2 includes an architecture overhaul, new YAML parsing engine, and 100% backwards compatibility for playbooks. It introduces task blocks for error handling and dynamic includes. Execution strategies allow running tasks linearly or in parallel. Many new modules were added.
- Galaxy 2 provides better metrics, role management, and Travis CI integration. It allows importing roles from organizations and individuals. The ansible-galaxy CLI was improved with features like role scaffolding and authentication.
3. Ansible 2 - Motivation
• Architecture overhaul
• New YAML parsing engine
• 100% backwards compatibility (playbooks)
• Ran out of Van Halen songs
4.
5. Task Blocks
---
- hosts: all
tasks:
- block:
- name: Script to connect the app to a monitoring service.
script: monitoring-connect.sh
rescue:
- name: This will only run in case of an error in the block.
debug: msg="There was an error in the block."
always:
- name: This will always run no matter what.
debug: msg="This always executes."
when: ansible_os_family == 'RedHat'
become: yes
tags: ['monitoring', 'redhat']
6. (Actually) Helpful Errors
$ ansible-playbook test.yml
ERROR! Syntax Error while loading YAML.
The error appears to have been in '/Users/jeff.geerling/test/test.yml':
line 9, column 1, but may be elsewhere in the file depending on the exact
syntax problem.
9. New Modules
• More for OpenStack, AWS, VMware, Windows, etc
• package module!
• apk, bundler, expect, find, iptables, pear,
puppet...
10. Variable Improvements
• Settable with vars at play, block, role, task levels
• Scoped to tasks contained within
tasks:
- block:
- name: Script to connect the app to a monitoring service.
script: monitoring-connect.sh
rescue:
- name: This will only run in case of an error in the block.
debug: msg="There was an error in the block."
vars:
workspace: "/tmp"
12. Breaking Changes
• Plugin API
• Ansible API
• Template code (doesn't turn bools/numbers into
strings)
• Empty/null variables (doesn't turn into strings)
13. More on Ansible 2
• Ansible 2.0 Launch (Ansible Blog)
• Ansible 2.0 Changelog
• Ansible 2.0 and Windows
14. Galaxy 2 - Motivation
• Galaxy was more or less unchanged since launch
in 2014.
• Role maintainers had to do a lot of manual work.
• Best practices started forming in the community
(e.g. testing).
• 'Organizations' weren't a thing; everything
namespaced to individuals.
16. Better role import UX
• Roles can be imported from Organizations or
individual users on GitHub. Easy as clicking
'import'
• To switch a role from username to organization,
delete then import again
18. Travis CI Integration
• Use Travis CI notification: to automatically
notify Galaxy on role updates and new tags:
1. Add Travis token to your Galaxy role settings
2. Enable the repo in Travis CI
3. Add notification config to .travis.yml
notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/
19. ansible-galaxy cli
• Role scaffold (init) includes basic Travis integration
• Better search, import, delete, setup and login