Book Image

Ansible Quick Start Guide

By : Mohamed Alibi
Book Image

Ansible Quick Start Guide

By: Mohamed Alibi

Overview of this book

Configuration Management (CM) tools help administrators reduce their workload. Ansible is one of the best Configuration Management tools, and can act as an orchestrator for managing other CMs. This book is the easiest way to learn how to use Ansible as an orchestrator and a Configuration Management tool. With this book, you will learn how to control and monitor computer and network infrastructures of any size,physical or virtual. You will begin by learning about the Ansible client-server architecture. To get started, you will set up and configure an Ansible server. You will then go through the major features of Ansible: Playbook and Inventory. Then, we will look at Ansible systems and network modules. You will then use Ansible to enable infrastructure automated configuration management, followed by best practices for using Ansible roles and community modules. Finally, you will explore Ansible features such as Ansible Vault, Ansible Containers, and Ansible plugins.
Table of Contents (15 chapters)
Title Page
Copyright and Credits
Packt Upsell
Contributors
Preface
Index

Preface

This is an Ansible guidebook for beginner systems administrators. It aims to properly introduce Ansible as an automation and configuration management tool. Readers of the book should, by the end, master basic use of Ansible playbooks and modules by learning from real-life sample codes that demonstrate each module's functionality to help achieve infrastructure and task automation and orchestration. The book contains some extra advanced tips for those who want to go the extra mile and learn about and collaborate with the Ansible community.

Who this book is for

This book is for three major audiences. First, systems administrators who work with either Linux, Windows, or Mac OS X. This covers those who work on bare-metal machines, virtual infrastructure, or cloud-based environments. Then, network administrators, those who work on distributed proprietary network equipment. Finally, DevOps. This book offers a good understanding of how the system they are going to deploy their application in will behave, enabling them to code accordingly or suggest modifications that can benefit their applications.

What this book covers

Chapter 1, What is Ansible?, is an introduction to Ansible and compares it with other configuration management tools.

Chapter 2, Ansible Setup and Configuration, explains how to set up and configure Ansible on multiple systems.

Chapter 3, Ansible Inventory and Playbook, is an introduction to and overview of Ansible Inventory and Playbook.

Chapter 4, Ansible Modules, covers Ansible's most often used modules with real-life sample usage code.

Chapter 5, Ansible Automated Infrastructure, enumerates Ansible's use cases for multiple infrastructures.

Chapter 6, Ansible Coding for Configuration Management, contains best practices for coding Ansible playbooks.

 

Chapter 7, Ansible Galaxy and Community Roles, is an introduction to Ansible community roles, usage, and contribution.

Chapter 8, Ansible Advanced Features, is an overview of some of Ansible's advanced features, such as Vault, plugins, and containers.

To get the most out of this book

Before reading this book, you should have a basic understanding of the Linux shell and some system administration skills in order to be able to follow the practical examples. Also, some basic coding skills will be very handy when dealing with YAML playbooks. As an optional requirement, having some basic knowledge of configuration management will help to simplify many points in the book.

To be able to run most of the code, we recommend having a virtual environment running at least two Linux machines, a Windows machine, and a Mac OS X. For network device testing, you may need a test network device or some virtual network equipment.

Download the example code files

You can download the example code files for this book from your account at www.packt.com. If you purchased this book elsewhere, you can visit www.packt.com/support and register to have the files emailed directly to you.

You can download the code files by following these steps:

  1. Log in or register at www.packt.com.
  2. Select the SUPPORT tab.
  3. Click on Code Downloads & Errata.
  4. Enter the name of the book in the Search box and follow the onscreen instructions.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR/7-Zip for Windows
  • Zipeg/iZip/UnRarX for Mac
  • 7-Zip/PeaZip for Linux

The code bundle for the book is also hosted on GitHub athttps://github.com/PacktPublishing/Ansible-Quick-Start-Guide. In case there's an update to the code, it will be updated on the existing GitHub repository.

We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Download the color images

We also provide a PDF file that has color images of the screenshots/diagrams used in this book. You can download it here: https://www.packtpub.com/sites/default/files/downloads/9781789532937_ColorImages.pdf.

Conventions used

There are a number of text conventions used throughout this book.

CodeInText: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: "Mount the downloaded WebStorm-10*.dmg disk image file as another disk in your system."

A block of code is set as follows:

$link = "https://raw.githubusercontent.com/ansible/ansible/devel/examples/scripts/ConfigureRemotingForAnsible.ps1"
$script = "$env:temp\ConfigureRemotingForAnsible.ps1"

(New-Object -TypeName System.Net.WebClient).DownloadFile($link, $script)

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

$link = "https://raw.githubusercontent.com/ansible/ansible/devel/examples/scripts/ConfigureRemotingForAnsible.ps1"
$script = "$env:temp\ConfigureRemotingForAnsible.ps1"

(New-Object -TypeName System.Net.WebClient).DownloadFile($link, $script)

 

Any command-line input or output is written as follows:

sudo apt install -y expect

Bold: Indicates a new term, an important word, or words that you see onscreen. For example, words in menus or dialog boxes appear in the text like this. Here is an example: "Select System info from the Administration panel."

Note

Warnings or important notes appear like this.

Note

Tips and tricks appear like this.

Get in touch

Feedback from our readers is always welcome.

General feedback: If you have questions about any aspect of this book, mention the book title in the subject of your message and email us at [email protected].

Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packt.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details.

Piracy: If you come across any illegal copies of our works in any form on the Internet, we would be grateful if you would provide us with the location address or website name. Please contact us at [email protected] with a link to the material.

If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.

 

 

Reviews

Please leave a review. Once you have read and used this book, why not leave a review on the site that you purchased it from? Potential readers can then see and use your unbiased opinion to make purchase decisions, we at Packt can understand what you think about our products, and our authors can see your feedback on their book. Thank you!

For more information about Packt, please visit packt.com.