Containerization with Ansible 2

Book description

Automate the container lifecycle from image build through cloud deployment using the automation language you already know.

About This Book

  • Use Ansible Container as an integral part of your workflow to increase flexibility and portability.
  • Manage the container life cycle using existing Ansible roles and automate the entire container build, deployment and management process.
  • A step-by-step guide that will get you up and running from building a simple container image to deploying a complex, multi-container app in the cloud.

Who This Book Is For

This book is aimed at DevOps engineers, administrators and developers who already have some familiarity with writing and running Ansible playbooks, and want to learn how to use Ansible to implement containerization.

What You Will Learn

  • Increase your productivity by using Ansible roles to define and build images
  • Learn how to work with Ansible Container to manage, test, and deploy your containerized applications.
  • Increase the flexibility and portability of your applications by learning to use Ansible
  • Discover how you can apply your existing Ansible roles to the image build process
  • Get you up and running from building a simple container image to deploying a complex, multi-container app in the cloud.
  • Take an indepth look at the architecture of Ansible Container, and learn how to build re-usable container images, reliably and efficiently.

In Detail

Today many organizations are adopting containerization and DevOps methodologies to improve the flexibility and reliability of deploying new applications. Building custom application containers often means leveraging brittle and oftentimes complex Dockerfiles that can lead to cumbersome, multi-layered containers. Ansible Container brings a new workflow for managing the development of containers from development all the way through to production. The goal of this book is to get you up and running with Ansible Container so that you can create container images from Ansible roles, run containers locally, and deploy them to the cloud.

We'll progress from a simple, single container application, to a complex application consisting of multiple, connected containers. You'll learn how to run the application locally, how to deploy it to an OpenShift cluster running locally, and how to deploy it to a Kubernetes cluster running in the cloud. Along the way, you'll see how to use roles to define each image or micro-service, and how to share your completed project with the Ansible community. Next, you will be able to take full advantage of Ansible Container, and use it to automate the container lifecycle in your own projects.

By the end of this book,you will gain mastery of the Ansible Container platform by building complex multi-container projects ready for deployment into production.

Style and approach

This book will walk you through Ansible Containerization from building a simple container image to deploying a complex, multi-container app in the cloud. You will get an in-depth understanding of how to effectively manage containers using Ansible 2.

Publisher resources

View/Submit Errata

Table of contents

  1. 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 color images for this book
      2. Errata
      3. Piracy
      4. Questions
  2. Building Containers with Docker
    1. DevOps and the shifting IT landscape
      1. Manual deployments of monolithic applications
      2. An introduction to automation
      3. Virtualization of applications and infrastructure
      4. Containerization of applications and infrastructure
      5. Orchestrating of containerized applications
    2. Building your first docker container
      1. Instantiating the lab environment
        1. Installing the lab environment:
      2. Starting your first Docker container
      3. Building your first container
        1. Dockerfiles
      4. Container life cycle management
      5. References
    3. Summary
  3. Working with Ansible Container
    1. An introduction to Ansible Container and the microservice architecture
    2. A quick introduction to Docker Compose
    3. Ansible Container workflow
    4. Ansible Container quick-start
      1. Ansible Container init
      2. Ansible Container build
      3. Ansible Container run
      4. Ansible Container destroy
    5. Summary
  4. Your First Ansible Container Project
    1. What are Ansible roles and container-enabled roles?
    2. Roles in Ansible Galaxy
    3. Ansible Container NGINX role
      1. Starting a new project
      2. Installing the NGINX role
      3. Running the NGINX role
      4. Modifying the NGINX role
      5. Running the modified role
      6. Pushing the project to Docker Hub
    4. Summary
  5. What's in a Role?
    1. Custom roles with Ansible Container
      1. YAML syntax
      2. Ansible modules
    2. A brief overview of MariaDB
    3. Initializing an Ansible Container role
      1. What's in a container-enabled role?
      2. Initializing the MariaDB project and role
        1. container.yml
      3. Writing a container-enabled role
        1. roles/mariadb_role/meta/container.yml
        2. tasks/main.yml
        3. Task breakdown (main.yml)
        4. tasks/initialize_database.yml
        5. Task breakdown (initialize_database.yml)
        6. templates/my.cnf.j2
      4. Building the container-enabled role
      5. Customizing the container-enabled role
        1. variable_files/dev.yml
        2. variable_files/test.yml
        3. variable_files/prod.yml
        4. container.yml
      6. References
    4. Summary
  6. Containers at Scale with Kubernetes
    1. A brief overview of Kubernetes
      1. Getting started with the Google Cloud platform
      2. Deploying an application in Kubernetes using kubectl
        1. Describing Kubernetes resources
        2. Exposing Kubernetes services
        3. Scaling Kubernetes pods
      3. Creating deployments using Kubernetes manifests
      4. Creating services using Kubernetes manifests
      5. References
    2. Summary
  7. Managing Containers with OpenShift
    1. What is OpenShift?
    2. Installing Minishift locally
      1. Installing the Minishift binaries
    3. Deploying containers using the web interface
      1. OpenShift web user interface tips
    4. An introduction to the OpenShift CLI
    5. OpenShift and Ansible Container
      1. References
    6. Summary
  8. Deploying Your First Project
    1. Overview of ansible-container deploy
      1. ansible-container deploy
      2. Deploying containers to Kubernetes
      3. Deploying containers to OpenShift
      4. References
    2. Summary
  9. Building and Deploying a Multi-Container Project
    1. Defining complex applications using Docker networking
    2. Exploring the Ansible Container django-gulp-nginx project
    3. Building the django-gulp-nginx project
      1. Development versus production configurations
    4. Deploying the project to OpenShift
      1. References
    5. Summary
  10. Going Further with Ansible Container
    1. Tips for writing roles and container apps
      1. Use full YAML syntax
      2. Use Ansible modules
    2. Build powerful deployment playbooks with Ansible Core
    3. Troubleshooting application containers
    4. Create a build pipeline using Jenkins or TravisCI
    5. Share roles and apps on GitHub and Ansible Galaxy
    6. Containerize everything!
      1. References
    7. Summary

Product information

  • Title: Containerization with Ansible 2
  • Author(s): Aric Renzo
  • Release date: December 2017
  • Publisher(s): Packt Publishing
  • ISBN: 9781788291910