Skip to content
O'Reilly home
Chef

Deploying Applications with Ansible

Automate your infrastructure in your data center and in the cloud

This event has ended.

What you’ll learn and how you can apply it

By the end of this live, online training course, you'll understand:

  • Why companies are choosing Ansible over other tools
  • Key Ansible concepts: variables, modules, playbooks, roles, and more
  • Best practices for writing reusable, maintainable code in Ansible

And you'll know how to:

  • Write Ansible roles and playbooks to automate routine operations tasks
  • Orchestrate deployments of multi-tier applications
  • Manage your infrastructure as code, whether in the cloud or the data center
  • Drive adoption of Ansible within your team through incremental adoption

This course is for you because…

  • You are a DevOps engineer with experience working on modern cloud architectures, and you need an automation tool capable of quickly iterating in an environment featuring a mix of newer services like Docker and Consul alongside legacy deployments.
  • You are an operations engineer whose company is migrating to the cloud, and you need a tool that can cope with both your existing data centers and new cloud applications.
  • You are a sysadmin with bash or Perl experience, and you need a more powerful tool to keep up with the increasing speed, scale, and complexity of your environment.

Prerequisites

Before the course, review the following:

Each student will be provided a live EC2 instance(s) with suitable configuration, managed through the instructor’s account. These instances will have baked in capabilities: Ansible, applications to be deployed, both app and Ansible monitoring/debugging tools, and remote access for the instructor (to permit logging in and helping ‘stuck’ students as time permits). The majority of the course will take place on these instances.

Schedule

The timeframes are only estimates and may vary according to how the class is progressing.

Day One

Introduction & Overview (5 mins)

  • Introduction to instructor and course
  • Overview of course goals and outline

Q&A (5 mins)

Installing Ansible (10 mins)

  • Describe the EC2 instance architecture for this course
  • Have students SSH into their EC2 instances
  • Describe how Ansible interfaces with your infrastructure: inventory, SSH, facts
  • Introduce the concept of Ansible modules
  • Give students a list of basic ad hoc modules to try in the remainder of the time

Q&A (5 mins)

Ansible Playbooks: Concepts (10 mins)

  • Introduce play/playbook syntax (YAML, building off syntax primer sent before class)
  • Introduce higher complexity modules, like ‘template’ or ‘copy’
  • Demo Ansible-playbook command

Ansible Playbooks: Structure (15 mins)

  • Playbook hosts
  • Playbook variables
  • Tasks
  • Multiple plays
  • Emphasize linear, 100% predictable execution order

Ansible Playbooks: Hands-On (15 mins)

  • Point out the pre-provided playbooks repository on the instance
  • Encourage students to extend a provided demo playbook with additional tasks
  • Point out how to find documentation about modules
  • Have students work towards deploying a basic web application (not expected to finish)

Break and Q&A (5 mins)

Ansible Roles: Concepts (15 mins)

  • Explain what roles are
  • Explain what reusable functionality they can bundle:

    • Tasks

    • Handlers
    • Variables
    • Files/templates
    • New modules

  • Show a few roles and directory structure

  • Contextualize roles in playbooks:

    • Pre/Post Tasks

    • Roles
    • Handlers

  • Show a more typical, role-heavy playbook

  • Explain where we get roles from:

    • Ansible Galaxy public roles

    • Custom roles with ansible-galaxy
    • Internal forks due to quality issues

  • Discuss what makes a role effective:

    • Code reuse

    • Composability

Break (5 mins)

Ansible Roles: Hands-On (20 mins)

  • Demo the Ansible-Galaxy command to create a role skeleton
  • Get students to convert parts of their web application playbook into roles

Q&A (5 mins)

Debugging Ansible Demo (5 mins)

  • Demo key debugging tools/commands

    • Verbose mode

    • SSH debugging
    • ps to look for Ansible processes
    • ANSIBLEKEEPREMOTE_FILES

Deploying Applications with Ansible—Individual Exercise (30 mins)

  • Use a mix of downloaded and hand-written roles to build a basic web application on provided AWS instances
  • Task will test students’ use of:

    • Playbooks

    • Variables
    • Roles
    • Inventory
    • Ansible commands

Ansible’s Strengths and Weaknesses (10 mins)

  • Summarize what we’ve learned so far
  • Present some perceived strengths/weaknesses of Ansible
  • Encourage learners to discuss, and tie it to what they’ve learned so far in their hands-on work

Recap of next day's plans and open Q&A (10 mins)

Day Two

Recap and Introduction to Day 2’s Material (5 mins)

  • Recap of what we covered
  • Describe goals for today again
  • Q&A on today’s/last night’s work

Key Ansible Modules (15 mins)

  • Cover the modules pointed to with individual documentation readings
  • Point out some important quirks/gotchas for these common modules
  • Module gotchas in general

Ansible Roles: Logic Demo (20 mins)

  • Look at an advanced role featuring lots of logic:

    • Conditionals, registration

    • Custom jinja filters
    • Shelling out
    • Loop friendly variables/gotchas

Break (5 mins)

Ansible at Scale Demo (10 mins)

  • First time looking at multiple-host Ansible runs
  • Connection types, ssh settings
  • High parallelism
  • Delegation
  • Rolling updates

Ansible in the Cloud (15 mins)

  • Explain dynamic inventories and cloud management modules
  • Have individuals create additional instances with Ansible
  • Use dynamic inventory to request data from each group's servers

Cloud Orchestration Group Exercise (30 mins)

  • Deploy a multi-tier, multi-instance application in AWS
  • Successfully serve traffic
  • Advanced goal: perform a rolling restart after an upgrade

Break and Q&A (10 mins)

Writing Maintainable Ansible Code (15 mins)

  • Encourage students to discuss, based on what they know, what would make Ansible more or less manageable/maintainable
  • Discuss testing

Ansible Roles: Analyzing Code Quality (15 mins)

  • Go over sample code from several public roles
  • Highlight areas of bad design: poor composability, variable naming, etc.
  • Link to some problematic roles and ask learners to discuss bad design choices

Break (5 mins)

Writing Your Own Ansible Modules and Plugins—Group Exercise (20 mins)

  • Discuss modules versus plugins
  • Describe API for modules
  • Task students to write a module to write a module, in the language of their choice

The Ansible Ecosystem (10 mins)

  • Start to wrap up course, terminate instances, etc.
  • Discuss important Ansible info sources and tools

    • github repo structure

    • Mailing lists
    • IRC
    • Ansible Tower
    • Support services
    • Other O’Reilly Ansible content

Recap of Course Goals / What We've Learned / Q&A (10mins)

Your Instructor

  • James Meickle

    James is a site reliability engineer at Quantopian, a crowd-sourced quantitative investment firm located in Boston, MA. His focus is developing the cloud architecture that supports the Quantopian community's Python trading algorithms. Prior to joining Quantopian, he worked as a site reliability engineer at Harvard, a developer evangelist at AppNeta, and a release engineer at Romney for President 2012.

    In his spare time James is a conference organizer for DevOpsDays Boston, now in its fourth year. He is also a meetup and conference speaker on topics including performance optimization, site reliability engineering, and devops tools. He is also quite committed to "soft skills" education focusing on organizational culture and human behavior, particularly when he can incorporate lessons learned from his background in psychology and political science.

Start your free 10-day trial

Get started

Want to learn more at events like these?

Get full access to O'Reilly online learning for 10 days—free.

  • checkmark50k+ videos, live online training, learning paths, books, and more.
  • checkmarkBuild playlists of content to share with friends and colleagues.
  • checkmarkLearn anywhere with our iOS and Android apps.
Start Free TrialNo credit card required.