Book description
Among the many configuration management tools available, Ansible has some distinct advantages—it’s minimal in nature, you don’t need to install anything on your nodes, and it has an easy learning curve. This practical guide shows you how to be productive with this tool quickly, whether you’re a developer deploying code to production or a system administrator looking for a better automation solution.
Author Lorin Hochstein shows you how to write playbooks (Ansible’s configuration management scripts), manage remote servers, and explore the tool’s real power: built-in declarative modules. You’ll discover that Ansible has the functionality you need and the simplicity you desire.
- Understand how Ansible differs from other configuration management systems
- Use the YAML file format to write your own playbooks
- Learn Ansible’s support for variables and facts
- Work with a complete example to deploy a non-trivial application
- Use roles to simplify and reuse playbooks
- Make playbooks run faster with ssh multiplexing, pipelining, and parallelism
- Deploy applications to Amazon EC2 and other cloud platforms
- Use Ansible to create Docker images and deploy Docker containers
Publisher resources
Table of contents
- Foreword
- Preface
- 1. Introduction
- 2. Playbooks: A Beginning
-
3. Inventory: Describing Your Servers
- The Inventory File
- Preliminaries: Multiple Vagrant Machines
- Behavioral Inventory Parameters
- Groups and Groups and Groups
- Hosts and Group Variables: Inside the Inventory
- Host and Group Variables: In Their Own Files
- Dynamic Inventory
- Breaking Out the Inventory into Multiple Files
- Adding Entries at Runtime with add_host and group_by
- 4. Variables and Facts
- 5. Introducing Mezzanine: Our Test Application
-
6. Deploying Mezzanine with Ansible
- Listing Tasks in a Playbook
- Organization of Deployed Files
- Variables and Secret Variables
- Using Iteration (with_items) to Install Multiple Packages
- Adding the Sudo Clause to a Task
- Updating the Apt Cache
- Checking Out the Project Using Git
- Installing Mezzanine and Other Packages into a virtualenv
- Complex Arguments in Tasks: A Brief Digression
- Creating the Database and Database User
- Generating the local_settings.py File from a Template
- Running django-manage Commands
- Running Custom Python Scripts in the Context of the Application
- Enabling the Nginx Configuration
- Installing TLS Certificates
- Installing Twitter Cron Job
- The Full Playbook
- Running the Playbook Against a Vagrant Machine
- Deploying Mezzanine on Multiple Machines
-
7. Complex Playbooks
- Running a Task on the Control Machine
- Running a Task on a Machine Other Than the Host
- Manually Gathering Facts
- Running on One Host at a Time
- Running Only Once
- Dealing with Badly Behaved Commands: changed_when and failed_when
- Retrieving the IP Address from the Host
- Encrypting Sensitive Data with Vault
- Patterns for Specifying Hosts
- Limiting Which Hosts Run
- Filters
- Lookups
- More Complicated Loops
- 8. Roles: Scaling Up Your Playbooks
- 9. Making Ansible Go Even Faster
-
10. Custom Modules
- Example: Checking That We Can Reach a Remote Server
- Using the Script Module Instead of Writing Your Own
- can_reach as a Module
- Where to Put Custom Modules
- How Ansible Invokes Modules
- Expected Outputs
- Implementing Modules in Python
- Documenting Your Module
- Debugging Your Module
- Implementing the Module in Bash
- Specifying an Alternaive Location for Bash
- Example Modules
- 11. Vagrant
-
12. Amazon EC2
- Terminology
- Specifying Credentials
- Prerequisite: Boto Python Library
- Dynamic Inventory
- Defining Dynamic Groups with Tags
- EC2 Virtual Private Cloud (VPC) and EC2 Classic
- Configuring ansible.cfg for Use with ec2
- Launching New Instances
- EC2 Key Pairs
- Security Groups
- Getting the Latest AMI
- Adding a New Instance to a Group
- Waiting for the Server to Come Up
- Creating Instances the Idempotent Way
- Putting It All Together
- Specifying a Virtual Private Cloud
- Building AMIs
- Other Modules
-
13. Docker
- The Case for Pairing Docker with Ansible
- Docker Application Life Cycle
- Dockerizing Our Mezzanine Application
- Creating Docker Images with Ansible
- The Other Container Images
- Deploying the Dockerized Application
- Starting the Database Container
- Retrieving the Database Container IP Address and Mapped Port
- Waiting for the Database to Start Up
- The Entire Playbook
- 14. Debugging Ansible Playbooks
- A. SSH
- B. Default Settings
- C. Using IAM Roles for EC2 Credentials
- Glossary
- Bibliography
- Index
Product information
- Title: Ansible: Up and Running
- Author(s):
- Release date: May 2015
- Publisher(s): O'Reilly Media, Inc.
- ISBN: 9781491915325
You might also like
video
Hands-on Ansible
3+ Hours of Video Instruction Hands-on Ansible LiveLessons is focused on hands-on training by providing the …
book
Ansible: Up and Running, 2nd Edition
Among the many configuration management tools available, Ansible has some distinct advantages—it’s minimal in nature, you …
video
Ansible Fundamentals LiveLessons
4 Hours of Video Instruction 4 hours of video to get you started using Ansible, focusing …
book
Learn Ansible
Run Ansible playbooks to launch complex multi-tier applications hosted in public clouds Key Features Build your …