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

Basic Ad hoc commands on Ansible


When automating or orchestrating tasks, Ansible is mainly used with playbooks to allow subtasks to be scripted and organized in a handy pipeline. However, Ansible also has various ad hoc commands. These allow the execution of a module on a host, or group of hosts, no matter how they are identified.

Once Ansible is installed, the ad hoc command line can be used directly. It can be easily tested, either by using it with the raw module or with some simple modules, such as ping or shell. As a quick example, each Ansible instance can ping itself using the following command:

ansible localhost -m ping

We should see the following output:

Note

The -moption indicates the module name that will be used while the task is running.

Some could question the Ansible ad hoc commands usefulness. They are actually a great way to test your tasks in depth, thereby making it easier to debug step-by-step smaller bits of a bigger task and capture the error location or troubleshoot slow...