Book Image

Ansible Configuration Management - Second Edition

By : Daniel Hall
Book Image

Ansible Configuration Management - Second Edition

By: Daniel Hall

Overview of this book

<p>Ansible is an open source software platform for configuring and managing computers. It provides a clear and concise way to manage the configuration of your Linux infrastructure. This book is a step-by-step guide that provides you with the knowledge you require to effectively manage your systems in a simple, quick, and maintainable way, with real-world examples.</p> <p>You will begin by learning the basics of Ansible and then move on to exploring more advanced topics. You will then learn the basic and complex operations of playbooks and interact with modules to manage Windows machines and deploy them. You will also get acquainted with Ansible's more advanced features such as serially updating machines, delegating tasks to other machines, advanced uses of variables, looping and conditions, copying whole directories, and using filters to process variables. Towards the end of the book, you will learn how to increase the functionality of Ansible itself by writing your own modules and plugins.</p>
Table of Contents (12 chapters)

Preface

Since CFEngine was first created by Mark Burgess in 1993, configuration management tools have been constantly evolving. Followed by the emergence of more modern tools such as Puppet and Chef, there are now a large number of choices available to a system administrator.

Ansible is one of the newer tools to arrive into the configuration management space. Where other tools have focused on completeness and configurability, Ansible has bucked the trend and, instead, focused on simplicity and ease of use.

In this book, we aim to show you how to use Ansible from the humble beginnings of its CLI tool, to writing playbooks, and then managing large and complex environments. Finally, we teach you how to build your own modules and extend Ansible by writing plugins that add new features.

What this book covers

Chapter 1, Getting Started with Ansible, teaches you the basics of Ansible, how to install it on Windows and Linux, how to build an inventory, how to use modules, and, most importantly, how to get help.

Chapter 2, Simple Playbooks, teaches you how to combine multiple modules to create Ansible playbooks to manage your hosts, it also covers a few useful modules.

Chapter 3, Advanced Playbooks, delves deeper into Ansible's scripting language and teaches you more complex language constructs; here we also explain how to debug playbooks.

Chapter 4, Larger Projects, teaches you the techniques to scale Ansible's configurations to large deployments using many complicated systems, including how to manage various secrets you may use to provision your systems.

Chapter 5, Custom Modules, teaches you how to expand Ansible beyond its current capabilities by writing both modules and plugins.

What you need for this book

To use this book, you will need at least the following:

  • A text editor

  • A machine with the Linux operating system

  • Python 2.6.x or Python 2.7.x

However, to use Ansible to its full effect, you should have several Linux machines available to be managed. You can use a virtualization platform to simulate many hosts, if required. To use the Windows modules, you will need both a Windows machine to be managed and a Linux machine to be the controller.

Who this book is for

This book is intended for people who want to understand the basics of how Ansible works. It is expected that you have rudimentary knowledge of how to set up and configure Linux machines. In parts of the book, we cover the configuration files of BIND, MySQL, and other Linux daemons; a working knowledge of these would be helpful, but is certainly not required.

Conventions

In this book, you will find a number of styles of text that distinguish among different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "This is done in a similar way using the vars_files directive."

A block of code is set as follows:

[group]
machine1
machine2
machine3

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

tasks:
  - name: install apache
    action: yum name=httpd state=installed

  - name: configure apache
    copy: src=files/httpd.conf dest=/etc/httpd/conf/httpd.conf

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

ansible machinename -u root -k -m ping

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "clicking the Next button moves you to the next screen".

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.