
This video gives an overview of the entire course.
In this video, we will see a real-world example of what Ansible can do and will set the stage for what the rest of the course has to teach.
Describe what Ansible is and the benefits of it
Show and describe Ansible demonstration
Discuss how Ansible makes software installation easy
In this video, we will explain how the core DevOps concepts of idempotence and immutable infrastructure are important to understand the use of Ansible.
Describe DevOps
Describe idempotence and its implications for safety
Describe immutable infrastructure and how it enables reliable systems
Ansible is not the only choice for infrastructure automation. In this video we will understand its design approach which helps us understand how it can best be used.
Explain that the Ansible has an agentless architecture for ease of use
Learn how Ansible uses YAML to record configuration for ease of maintenance
Choose simplicity in its approach to automate infrastructure
Installing Ansible is easy through Python packages. To use it, we also need to understand how to configure SSH and sudo. In this video we will see that.
Install Ansible using Python packages
Configure SSH and sudo to allow remote machine control
Use a ping test to verify remote management with Ansible
In this video we will use our configured Ansible to run commands across multiple machines.
Check status of multiple servers with one Ansible command
Install a package on multiple servers with one Ansible command
Restart a service on multiple servers with one Ansible command
In this video we will learn to run Ansible consistently against a set of systems, we need to record a list in the format Ansible expects.
Create a plain text inventory file
Configure OpenSSH to connect to remote systems
Run ansible-playbook to verify our configuration
In this video we will learn to specify the list of tasks Ansible should automate, we need to understand playbook files.
Understand how tasks and plays make up a playbook
Understand how to use YAML syntax to make tasks and plays
See how a playbook file is organized
Now that we understand playbook files, in this video we’re ready to see our first example.
Understand how to provide parameters to a task
See how handlers can be used to run commands only if a task is changed
Run a complete Ansible playbook to verify our understanding of tasks and handlers
The aim of this video is to record per-system customisation in a place that can be stored in version control.
Customize Ansible’s SSH connection to a system
Customize how Ansible gets necessary admin privileges
See how Ansible can connect to Windows systems and Docker containers
In this video, we will see how Ansible can apply the same configuration and plays to multiple systems using groups.
Add a system to a group in the inventory file
Create a group of groups and add custom configuration to it
Configure the playbook to run tasks for a specific group or for all systems
As we add more tasks to an Ansible playbook, it takes longer and longer to run. In this video we will run only part of the playbook so things get executed faster.
Limit a playbook run to a specific group or system
Limit a playbook run to specific tasks with a tag
Combine group limits and tags to target a playbook run
To use Ansible roles effectively, we need to understand what they’re for and how they’re organized.
Learn how roles can help organize Ansible automation
See the parts of a role and how it’s built
See how an Ansible playbook references a role
Ansible has a lot of modules, and a new user needs to know which ones are most important and how they work.
See some commonly used packaging module
See some commonly used file modules
See some commonly used system modules
Ansible Galaxy has many user contributed roles we can reuse. In this video, we will learn how to install and use them.
Search for a role on Ansible Galaxy
Install and inspect an Ansible Galaxy role
Use the Ansible Galaxy role in a playbook
To build our own roles, we need to understand how handlers, files, and templates are used in a role.
See an example of a role handler
See an example of a file in a role
See an example of a template in a role
Ansible roles often have dependencies on other roles. By configuring these dependencies in a role, we can make our playbooks more concise.
Understand how to declare a role as a dependency of another role
Understand how to configure a dependency of a role
See an example of using the same dependent role multiple times
Ansible templates are powerful but they require us to understand the Jinja2 template language.
Review the Ansible template module
Perform a basic variable substitution in a template
See how template changes cause updates on the system
We have sections within a configuration file that need to be turned on or off easily.
Understand Jinja2 control statements
Use an if statement to include or exclude a section of a template
Create compound conditional statements for advanced behavior
To make our templates more generic and reusable, we want to move hardcoded lists and data structures to variables.
Create a for loop over a YAML list
Build a complex YAML data structure and pull values from it into a template
Use a Jinja2 macro to more easily repeat similar content
To do more advanced data manipulation in a template, we need to understand Jinja2 filters.
Use the default filter to handle cases where a variable is not defined
Use a join filter to create a comma-separated string from a YAML list
Use a map filter to extract individual fields from a complex YAML data structure
Jinja2 blocks and inheritance provide us with a way to create many similar templates from a common base.
Create a base template with common content
Extend the base template by defining block content
Understand how the base and child templates work together to create the output file
To create generic and reusable roles, we need to allow role users to configure the role behavior using variables.
Describe how Ansible uses variables to configure tasks and templates
Discuss the hierarchy for variable values
Illustrate how variables can be specified inside and outside the role to modify role behavior
Some configuration might be specific to the system we’re configuring. Ansible provides system-specific facts to help tailor configuration to a system.
Show how facts can be used as variables but don’t need to be defined manually
Demonstrate running the setup module to see a list of facts
Discuss some important facts that Ansible makes available
By putting systems into groups in Ansible, we can apply configuration to multiple systems at the same time.
Show where Ansible looks for group variables
Show how Ansible can perform variable substitution into other variables
Show where Ansible looks for host-specific variables
Some tasks may apply only to certain types of systems or only in certain scenarios. Conditional tasks allow us to run tasks only in some cases.
Create conditional tasks for different Linux distributions
Demonstrate how Ansible runs or skips tasks based on conditionals
Look at specific examples for compound task conditions
To decide whether or how to run a task, we might need to collect dynamic information from a host we’re controlling. Ansible allows us to register results in variables.
Register stat information for a file in a variable
Show how to use the registered information to control tasks
Inspect the detailed information provided
By driving tasks using YAML list and dictionary data structures, we can produce more compact and more configurable roles.
Use a YAML list to install multiple packages to a system
Use a YAML dictionary to identify multiple configuration files to create on a system
Use the YAML dictionary data to drive the contents of the multiple configuration files we created
Installing and configuring software requires us to keep secret information like passwords to use in configuration. We need to put our Ansible content into version control without exposing these secrets.
Understand how Ansible works well with version control tools
Consider how to handle secret information when using version control
See how Ansible Vault encrypts secrets so the data can be safely stored in version control
To use Ansible Vault to keep secrets secure, we need to know how to encrypt files. We also need to know how to edit and decrypt files we encrypted.
Encrypt a file using Ansible Vault
Use the encrypted file when running an Ansible playbook
Edit and decrypt a file encrypted by Ansible Vault
Running Ansible unattended while using Ansible Vault requires us to store our vault password in a file.
See a few ways to generate secure passwords and store a password to a file
Understand how to keep a password file from being committed to a Git repository
See how to use a password file with Ansible commands
Some secret content, such as a private key file for a web server, is an entire file’s worth of content. We need to know how to store that content securely using Ansible Vault.
Discuss using Ansible Vault to encrypt an entire file
Show how encrypted file content can be brought in from outside a role
Show how to embed an entire file’s content into a YAML variable literal
Adding new functionality to Ansible involves implementing a custom module in the Python language. We can easily add this custom module to a role.
See an Ansible role with a custom module included
Run an Ansible playbook that uses a custom module and see the results
See the overall structure of a Python file that implements an Ansible custom module
Our custom module needs to receive data from Ansible, then pass results back. To get parameters from Ansible, we need to let Ansible know what arguments our module supports.
Declare a dictionary of module arguments
Ask Ansible to build our module parameters using the task data and our dictionary
Populate a results object and send it back to Ansible
A well-written module will only report change when an actual change occurs on the remote system.
Build helper functions to allow our custom module to query current state
Use current state to determine if our module needs to make changes
Make changes only when required and report back to Ansible whether changes were made
To develop our module, we need to be able to run it in a realistic environment without having to create or run an Ansible playbook.
See how users can use check mode with our module to make sure their tasks are correct
Set up our module file to be run as a top level Python script
Create a file with module arguments and a test script to run our module in test mode
A quality module has extensive documentation to show users how to use it. This documentation is also used to generate the Ansible website.
Describe our module’s purpose, inputs, and results using documentation
Provide examples for how to use our module directly in the module file
See how Ansible metadata and documentation is used to generate the Ansible website
Ansible can control not just physical and virtual machines, but also Docker containers. This creates new opportunities to use Ansible roles and playbooks in a containerized environment.
Understand the difference between virtual machines and containers
Run a Docker container
Run an Ansible playbook against the Docker container and see the results
Vagrant is a useful tool for dynamically creating virtual machines for development and test in an integrated environment. Ansible lets us set up Vagrant virtual machines quickly and easily.
Show how Vagrant lets us build a virtual machine from a template box
Use Ansible as a provisioner for our Vagrant virtual machine
Connect into our Vagrant virtual machine and see the provisioned result
Vagrant is a tool for dynamic virtual machines, and when we’re using Ansible to provision Vagrant machines, we want to be able to pass information to Ansible dynamically as well.
Pass data from environment variables through Vagrant to Ansible
Build a Vagrant file that creates multiple virtual machines
Pass dynamic data to Ansible about the Vagrant virtual machines we created
In a horizontally scalable cloud architecture, we need to be able to start many virtual machines with software already installed and configured. Packer and Ansible can work together to build ready-to-use images for the cloud.
Understand how Packer builds disk images using Ansible
Run Packer to create a new Amazon Machine Image
See the resulting AMI ready to use in a cloud environment
To use Docker effectively, we want a Docker image that already has the result of our Ansible roles applied. Packer can use Ansible to provide this Docker image.
Discuss building images using a Docker file versus using Packer and Ansible
Review a Packer configuration to create a Docker image
Run Packer and Ansible to build the Docker image and see the result
This video provides an overview of the entire course.
A DevOps pipeline can automate software build and deployment, but it must include complex and sophisticated tasks. Ansible can automate those tasks.
Describe the DevOps pipeline
Show how Ansible helps with DevOps
Demonstrate a DevOps pipeline with Ansible
To get the advantages of DevOps, we need to understand what DevOps is and why it is important.
Understand the DevOps culture, tools, and mindset
Discuss the flow from development to production
Understand how monitoring flows data back to development
Correctly setting up our DevOps pipeline is important. Ansible can help us not only in our DevOps pipeline but also in setting up the pipeline itself.
See how Ansible uses playbooks for automation
Set up a Gitlab CI server with Ansible
Install Ansible itself using Ansible
Deploying to a cloud environment such as Amazon Web Services requires us not only to build our software but also to assemble a complete system.
Show the difference between build artifacts and an assembled application
Show how Ansible helps us perform our application assembly
Demonstrate deploying a complete application to Amazon Web Services
Rapid deployment of an application to AWS requires a prebuilt machine image. We can automate this build with Packer and Ansible.
Describe how Packer works to build machine images
Show how Packer integrates with AWS
Show how Packer uses Ansible to provision the machine it is building
As our use of Ansible gets more sophisticated, we need to organize our automation into roles so that we can better maintain and reuse our work.
Use a role from an Ansible playbook file
Download and use a pre-made role from Ansible Galaxy
Build a custom role to install and configure a custom application
The roles we download or build ourselves contain complex information about how to configure a piece of software. Templates and variables allow us to simplify that information to make it easy to modify.
Deploy a configuration file using the Ansible template module
Define variables in templates to better customize our role
Declare variables outside the role to control the role’s behavior
Automating software configuration requires access to secret information like credentials. Ansible Vault will allow us to store that information safely.
Encrypt a variable file with Ansible Vault
Edit a file while it is in an encrypted state
Use an encrypted file as part of an Ansible playbook run
Installing into a cloud environment like AWS is complex because of the dynamic networking involved. Ansible provides tools to simplify this process.
Build an inventory file to manage virtual machines in AWS
Run an Ansible playbook against an AWS virtual machine
See how Ansible can dynamically generate its inventory based on our current AWS configuration
Deploying an application to AWS requires using multiple different resources. Ansible can automate creating and modifying these resources so we can keep our application up-to-date without any downtime.
Understand how AWS rolling updates work
Deploy AWS resources using Ansible
Roll our AWS deployment to a new application version with zero downtime
To test an application that requires multiple virtual machines, we need a tool like Vagrant that is designed to dynamically create and provision virtual machines.
Understand how Vagrant works and what it is for
Configure Vagrant using a Vagrantfile
Use Ansible to provision a Vagrant virtual machine
With Vagrant and Ansible working together, we can build a test environment that deploys an instance of our application, runs tests, and then clean up.
Add tasks to Ansible to perform testing and report results
Configure Ansible via Vagrant using environment variables
Run an integration test with Vagrant and Ansible
To make our integration test as realistic as possible, we are going to deploy our application to the same AWS environment we use for production.
Increase the capabilities of Vagrant using plugins
Install the Vagrant AWS plugin
Configure our Vagrantfile to create dynamic virtual machines in AWS
Our new integration test should run automatically whenever the application changes. We can use Jenkins to launch our integration test.
Create a Jenkinsfile to configure the integration test
Assign the Jenkins job to a build slave with Vagrant and Ansible installed
Run the Jenkins job automatically when the application changes
Ansible provides two separate ways to build Docker containers from an Ansible playbook and we need to understand the advantages of each one.
Demonstrate the Ansible Docker Connector
Demonstrate the Ansible docker_image module
Discuss the advantages of each approach for using Ansible to build Docker containers
Ansible provides a simple and sophisticated solution for running applications based on Docker.
Use the docker_container module to run Docker containers
Use the docker_volume module to create persistent storage for containers
Show how we can use Docker automated host resolution to simplify application configuration
To use our containerized application in a container orchestration environment, we need to push our Docker image to a registry with a unique tag for each build.
Configure Docker push using the docker_login module
Use extra variables to create unique tag names for each build
Use the docker_image module to push to a registry as part of the build
To perform a rolling update of our containerized application running in Docker, we need to understand how to use Docker Compose in our Ansible playbook.
Use the docker_service module to define our application for Docker Compose
Deploy our Docker Compose application using Ansible
Use Ansible to roll our application to a new version with zero downtime
We need an automated test for our containerized application. We can use Docker to create a test environment, making it easy to clean up when our test is done.
Configure Gitlab CI to automatically run our containerized test
Build a test script that uses Docker to create a temporary test environment
Capture the result of the test and return the result to Gitlab CI
To control resources in Kubernetes, we can use Ansible’s k8s_raw module, but we must configure it with the necessary authentication information for the Kubernetes API server.
Show the k8s_raw module in an Ansible playbook
Identify how to specify authentication information for Kubernetes
Demonstrate an Ansible playbook that deploys to Kubernetes
Kubernetes has a unique set of resources that together allow us to deploy an application. We need to understand what resources to use for our application.
Build persistent storage for our application’s database
Create a database deployment and service
Create our application’s deployment and service
Application integration tests can require multiple components to work together. Kubernetes and Ansible can allow us to deploy our application for testing.
Create a unique namespace to keep our test separate
Create a test pod that runs a test version of our application
Execute our test within the test pod and report the results
To deploy our application to Kubernetes using Ansible, we need to understand how each of the Kubernetes resources are declared in the playbook.
Define the persistent storage for our application
Pull in the database and application service definitions from a separate file
Use Ansible’s lookup function to populate variables to properly define our database and application deployments
We need to keep our application running in Kubernetes even while we deploy new versions. We can use Ansible to simplify our Kubernetes rolling updates.
Run our Ansible playbook and review the resulting Kubernetes resources
Expose our application’s service through a port on the Kubernetes host and access it in a browser
Roll our application to a new version and see how Kubernetes updates a pod at a time to avoid downtime
Ansible is a simple IT automation engine, that automates cloud provisioning, configuration management, application deployment, intra-service orchestration, and many other IT needs. Designed for multi-tier deployments since day one, Ansible models your IT infrastructure by describing how all your systems interrelate, rather than managing one system at a time.
This comprehensive 2-in-1 course is comprehensive, hands-on course with discovery of orchestration, DevOps and automation using Ansible. Explore Ansible with cloud services and its AWS provisioning. Understand infrastructure automation and decide what makes Ansible a good choice for your projects. Get started with Ansible through playbooks and organize the automation of infrastructure tasks by building and using roles from Ansible Galaxy. Use the best DevOps practices to automate your building and testing environments to push your software into production.
This training program includes 2 complete courses, carefully chosen to give you the most comprehensive training possible.
The first course, Hands-On Infrastructure Automation with Ansible, covers practical course for beginners to Ansible and deployment of applications the right way. Use Ansible to automate deployment so you can quickly and reliably run and upgrade your applications. Infrastructure Automation results in cost reduction, productivity, availability, reliability, and performance. Gain real-world experience on your own deployments.
In the second course, Hands-On DevOps with Ansible, you will learn how a DevOps pipeline can speed up your software development. You will use DevOps practices to automate your building and testing environments to push software into production. You will use Ansible to automate your DevOps pipeline. Whether you test and deploy applications on-premise or in the cloud, and whether you build full systems or containers with Docker and Kubernetes, you will be able to develop and deploy reliable applications with speed using Ansible.
By the end of this course, you’ll be able to create and maintain Ansible playbooks, roles, and custom modules, enabling you to make full use of Ansible as part of a DevOps or automation strategy.
Meet Your Expert(s):
We have the best work of the following esteemed author(s) to ensure that your learning journey is smooth:
Alan Hohn is a Software Architect who primarily works with distributed Java. He has had a lot of experience re-architecting embedded systems and in combining embedded and enterprise approaches. Lately he has been doing quite a bit of work with virtualization, DevOps, and cloud technologies. Over the past several years, he has had the opportunity to teach courses on Java. His role and interest also mean that he frequently tries out new libraries and new approaches. His hope is that some of that material will be as useful to others as he has occasionally found it. He is employed by Lockheed Martin Mission Systems and Training and his personal blog is called Variegated.