Transcript
Page 1: Ansible 2 and Ansible Galaxy 2

Ansible 2 Ansible Galaxy 2

Jeff Geerling (geerlingguy)

Ansible St. Louis Meetup - 2016-03-09

Page 2: Ansible 2 and Ansible Galaxy 2

www.ansiblefordevops.com

Page 3: Ansible 2 and Ansible Galaxy 2

Ansible 2 - Motivation

• Architecture overhaul

• New YAML parsing engine

• 100% backwards compatibility (playbooks)

• Ran out of Van Halen songs

Page 4: Ansible 2 and Ansible Galaxy 2
Page 5: Ansible 2 and Ansible Galaxy 2

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']

Page 6: Ansible 2 and Ansible Galaxy 2

(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 exactsyntax problem.

Page 7: Ansible 2 and Ansible Galaxy 2

Dynamic Includes

- include: test.yml with_items: - 1 - 2 - 3 when: runtime_variable_is_true

Page 8: Ansible 2 and Ansible Galaxy 2

Execution Strategies

• Built-in:

• linear - standard one-by-one, wait for all hosts

• free - hosts go as fast as they can

Page 9: Ansible 2 and Ansible Galaxy 2

New Modules

• More for OpenStack, AWS, VMware, Windows, etc

• package module!

• apk, bundler, expect, find, iptables, pear, puppet...

Page 10: Ansible 2 and Ansible Galaxy 2

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"

Page 11: Ansible 2 and Ansible Galaxy 2

Inventory

• Added meta: refresh_inventory to force reload

Page 12: Ansible 2 and Ansible Galaxy 2

Breaking Changes

• Plugin API

• Ansible API

• Template code (doesn't turn bools/numbers into strings)

• Empty/null variables (doesn't turn into strings)

Page 13: Ansible 2 and Ansible Galaxy 2

More on Ansible 2

• Ansible 2.0 Launch (Ansible Blog)

• Ansible 2.0 Changelog

• Ansible 2.0 and Windows

Page 14: Ansible 2 and Ansible Galaxy 2

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.

Page 15: Ansible 2 and Ansible Galaxy 2

Better metrics

• GitHub stars and watchers

• Download counts

• Travis test status built in

Page 16: Ansible 2 and Ansible Galaxy 2

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

Page 17: Ansible 2 and Ansible Galaxy 2

Better role management• Role management on Galaxy is much better

Page 18: Ansible 2 and Ansible Galaxy 2

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/

Page 19: Ansible 2 and Ansible Galaxy 2

ansible-galaxy cli

• Role scaffold (init) includes basic Travis integration

• Better search, import, delete, setup and login

Page 20: Ansible 2 and Ansible Galaxy 2

More on Galaxy 2

• Ansible Galaxy 2.0 Launches

Page 21: Ansible 2 and Ansible Galaxy 2

__________ < the end! > ---------- \ ^__^ \ (oo)\_______ (__)\ )\/\ ||----w | || ||


Recommended