Learning Ansible 2 - Second Edition

Book description

Learn everything you need to manage and handle your systems with ease with Ansible 2 using this comprehensive guide

About This Book

  • Simplify the automation of applications and systems using the newest version of Ansible
  • Get acquainted with fundamentals of Ansible such as playbooks, modules, and various testing strategies
  • A comprehensive, learning guide that provides you with great skills to automate your organization’s infrastructure using Ansible 2

Who This Book Is For

The book is for sys admins who want to automate their organization’s infrastructure using Ansible 2. No prior knowledge of Ansible is required.

What You Will Learn

  • Set up Ansible 2 and an Ansible 2 project in a future-proof way
  • Perform basic operations with Ansible 2 such as creating, copying, moving, changing, and deleting files, and creating and deleting users
  • Deploy complete cloud environments using Ansible 2 on AWS and DigitalOcean
  • Explore complex operations with Ansible 2 (Ansible vault, e-mails, and Nagios)
  • Develop and test Ansible playbooks
  • Write a custom module and test it

In Detail

Ansible is an open source automation platform that assists organizations with tasks such as configuration management, application deployment, orchestration, and task automation. With Ansible, even complex tasks can be handled easier than before.

In this book, you will learn about the fundamentals and practical aspects of Ansible 2 by diving deeply into topics such as installation (Linux, BSD, and Windows Support), playbooks, modules, various testing strategies, provisioning, deployment, and orchestration. In this book, you will get accustomed with the new features of Ansible 2 such as cleaner architecture, task blocks, playbook parsing, new execution strategy plugins, and modules. You will also learn how to integrate Ansible with cloud platforms such as AWS. The book ends with the enterprise versions of Ansible, Ansible Tower and Ansible Galaxy, where you will learn to interact Ansible with different OSes to speed up your work to previously unseen levels

By the end of the book, you’ll able to leverage the Ansible parameters to create expeditious tasks for your organization by implementing the Ansible 2 techniques and paradigms.

Style and approach

This book is a step-by-step learning guide on the all new Ansible 2, which is an ideal configuration management tool.

Table of contents

  1. Learning Ansible 2 Second Edition
    1. Learning Ansible 2 Second Edition
    2. Credits
    3. About the Author
    4. About the Reviewer
    5. www.PacktPub.com
      1. Why subscribe?
    6. Preface
      1. What this book covers 
      2. What you need for this book 
      3. Who this book is for
      4. Conventions 
      5. Reader feedback
      6. Customer support
        1. Downloading the example code 
        2. Errata
        3. Piracy
        4. Questions
    7. 1. Getting Started with Ansible
      1. IT automation
        1. The history of IT automation
        2. Advantages of IT automation
        3. Disadvantages of IT automation
          1. Limiting the possible damages of an error propagation
        4. Types of IT automation
          1. Agent-based systems
          2. Agent-less systems
          3. Agent-based versus Agent-less systems
      2. What is Ansible?
      3. Secure Shell (SSH)
      4. Why Ansible?
      5. Installing Ansible
        1. Installing Ansible using the system's package manager
          1. Installing via Yum
          2. Installing via Apt
          3. Installing via Homebrew
          4. Installing via pip
          5. Installing Ansible from source
      6. Creating a test environment with QEMU and KVM
      7. Version control system
      8. Using Ansible with Git
      9. Summary
    8. 2. Automating Simple Tasks
      1. YAML
      2. Hello Ansible
      3. Working with playbooks
        1. Studying the anatomy of a playbook
        2. Running a playbook
      4. Ansible verbosity
      5. Variables in playbooks
      6. Creating the Ansible user
      7. Configuring a basic server
        1. Enabling EPEL
        2. Installing Python bindings for SELinux
        3. Upgrading all installed packages
        4. Ensuring that NTP is installed, configured, and running
        5. Ensuring that FirewallD is present and enabled
        6. Adding a customized MOTD
        7. Changing the hostname
        8. Reviewing and running the playbook
      8. Installing and configuring a web server
      9. Publishing a website
      10. Jinja2 templates
        1. Variables
        2. Filters
        3. Conditionals
        4. Cycles
      11. Summary
    9. 3. Scaling to Multiple Hosts
      1. Working with inventory files
        1. The basic inventory file
        2. Groups in an inventory file
        3. Regular expressions in the inventory file
      2. Working with variables
        1. Host variables
        2. Group variables
        3. Variable files
        4. Overriding configuration parameters with an inventory file
      3. Working with dynamic inventory
        1. Amazon Web Services
        2. DigitalOcean
      4. Working with iterates in Ansible
        1. Standard iteration - with_items
        2. Nested loops - with_nested
        3. Fileglobs loop - with_fileglobs
        4. Integer loop - with_sequence
      5. Summary
    10. 4. Handling Complex Deployment
      1. Working with the local_action feature
      2. Delegating a task
      3. Working with conditionals
        1. Boolean conditionals
        2. Checking if a variable is set
      4. Working with include
      5. Working with handlers
      6. Working with roles
        1. Project organization
        2. Anatomy of a role
        3. Transforming your playbooks in a full Ansible project
          1. Transforming a playbook into a role
          2. Helper files
          3. Transforming the webserver role
          4. Handlers in roles
      7. Execution strategies
      8. Tasks blocks
      9. The Ansible template - Jinja filters
        1. Formatting data using filters
        2. Using filters with conditionals
        3. Defaulting undefined variables
      10. Security management
        1. Using Ansible vault
        2. Vaults and playbooks
        3. Encrypting user passwords
        4. Hiding passwords
        5. Using no_log
      11. Summary
    11. 5. Going Cloud
      1. Provisioning resources in the cloud
      2. Amazon Web Service
        1. AWS global infrastructure
        2. AWS Simple Storage Service
        3. AWS Elastic Compute Cloud (EC2)
        4. AWS Virtual Private Cloud (VPC)
        5. AWS Route 53
        6. AWS Elastic Block Storage (EBS)
        7. AWS Identity and Access Management
        8. Amazon relational database service
        9. Setting up an account with AWS
        10. Simple AWS deployment
        11. Complex AWS deployment
      3. DigitalOcean
        1. Droplets
        2. SSH key management
        3. Private networking
        4. Adding an SSH key in DigitalOcean
        5. Deployment in DigitalOcean
      4. Summary
    12. 6. Getting Notifications from Ansible
      1. E-mails
      2. XMPP
      3. Slack
      4. Rocket Chat
      5. Internet Relay Chat (IRC)
      6. Amazon Simple Notification Service
      7. Nagios
      8. Summary
    13. 7. Creating a Custom Module
      1. Using Python modules
        1. Working with exit_json and fail_json
        2. Testing Python modules
      2. Using bash modules
      3. Using Ruby modules
      4. Testing modules
      5. Summary
    14. 8. Debugging and Error Handling
      1. The check mode
      2. Indicating differences between files using --diff
      3. Functional testing in Ansible
      4. Functional testing using assert
      5. Testing with tags
      6. The --skip-tags
      7. Managing exceptions
      8. Trigger failure
      9. Summary
    15. 9. Complex Environments
      1. Code based on the Git branch
      2. A single stable branch with multiple folders
      3. Software distribution strategy
        1. Copying files from the local machine
        2. Revision control system with branches
        3. Revision control system with tags
        4. RPM packages
      4. Preparing the environment
      5. Deploying a web app with revision control systems
      6. Deploying a web app with RPM packages
        1. Creating a Spec file
        2. Building RPMs manually
        3. Building RPMs with Ansible
        4. Building RPMs with CI/CD pipelines
      7. Building compiled software with RPM packaging
      8. Deployment strategies
        1. Canary deployment
        2. Blue/Green deployment
      9. Optimizations
        1. Pipelining
        2. Optimizing with_items
        3. Understanding what happens when your tasks are executed
      10. Summary
    16. 10. Introducing Ansible for Enterprises
      1. Ansible on Windows
      2. Ansible for networking devices
      3. Ansible Galaxy
      4. Ansible Tower
      5. Summary

Product information

  • Title: Learning Ansible 2 - Second Edition
  • Author(s): Fabio Alessandro Locati
  • Release date: November 2016
  • Publisher(s): Packt Publishing
  • ISBN: 9781786464231