Ansible 2 and Ansible Galaxy 2

  • View
    2.938

  • Download
    6

Embed Size (px)

Transcript

  • Ansible 2 Ansible Galaxy 2

    Jeff Geerling (geerlingguy)

    Ansible St. Louis Meetup - 2016-03-09

  • www.ansiblefordevops.com

    http://www.ansiblefordevops.com

  • Ansible 2 - Motivation

    Architecture overhaul

    New YAML parsing engine

    100% backwards compatibility (playbooks)

    Ran out of Van Halen songs

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

  • (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.

  • Dynamic Includes

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

  • Execution Strategies

    Built-in:

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

    free - hosts go as fast as they can

  • New Modules

    More for OpenStack, AWS, VMware, Windows, etc

    package module!

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

  • 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"

  • Inventory

    Added meta: refresh_inventory to force reload

  • Breaking Changes

    Plugin API

    Ansible API

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

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

  • More on Ansible 2

    Ansible 2.0 Launch (Ansible Blog)

    Ansible 2.0 Changelog

    Ansible 2.0 and Windows

    http://www.ansible.com/blog/ansible-2.0-launchhttps://github.com/ansible/ansible/blob/devel/CHANGELOG.mdhttps://www.ansible.com/ansible-2-windows

  • 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.

  • Better metrics

    GitHub stars and watchers

    Download counts

    Travis test status built in

  • 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

  • Better role management Role management on Galaxy is much better

  • 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/

  • ansible-galaxy cli

    Role scaffold (init) includes basic Travis integration

    Better search, import, delete, setup and login

  • More on Galaxy 2

    Ansible Galaxy 2.0 Launches

    https://www.ansible.com/blog/ansible-galaxy-2-release

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