Ansible Quick Start Guide
Control and monitor infrastructures of any size, physical or virtual
Mohamed Alibi
- 214 pages
- English
- ePUB (mobile friendly)
- Available on iOS & Android
Ansible Quick Start Guide
Control and monitor infrastructures of any size, physical or virtual
Mohamed Alibi
About This Book
Configure Ansible and start coding YAML playbooks using the appropriate modules
Key Features
- Create and use Ansible Playbook to script and organise management tasks
- Benefit from the Ansible community roles and modules to resolve complex and niche tasks
- Write configuration management code to automate infrastructure
Book Description
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.
What you will learn
- Implement Playbook YAML scripts and its capacities to simplify day-to-day tasks
- Setup Static and Dynamic Inventory
- Use Ansible predefined modules for Linux, Windows, networking, and virtualisation administration
- Organize and configure the host filesystem using storage and files modules
- Implement Ansible to enable infrastructure automated configuration management
- Simplify infrastructure administration
- Search and install new roles and enable them within Ansible
- Secure your data using Ansible Vault
Who this book is for
This book is targeted at System Administrators and Network Administrators who want to use Ansible to automate an infrastructure. No knowledge of Ansible is required.
Frequently asked questions
Information
Ansible Modules
- Overview of the use of Ansible modules
- Ansible Linux modules and their varieties
- Implementing Ansible Windows modules
- A common constructor: Ansible network modules
- The Ansible cloud modules of the big three cloud providers
Ansible modules overview
ansible-doc apt
ansible-doc -l
Ad hoc versus playbook: the ping module
ansible servers -m ping
---
- name: Ping module playbook usage
hosts: servers
gather_facts: false
tasks:
- name: ping the local servers
ping:
Ad hoc versus playbook: the win_reboot module
ansible winservers -m win_reboot
ansible win servers -m win_reboot āargs="msg='Reboot initiated by remote admin' pre_reboot_delay=5"
---
- name: Reboot Windows hosts
hosts: winservers
fast_gathering: false
tasks:
- name: restart Windows hosts with default settings
win_reboot
- name: restart Windows hosts with personalized
settings
win_reboot:
msg: "Reboot initiated by remote admin"
pre_reboot_delay: 5
ad-hoc versus playbook: the copy module
ansible servers -m copy --args="src=./file1.txt dest=~/file1.txt"
---
- name: copy a file to hosts
hosts: servers
become: true
fast_gathering: false
tasks:
- name: copy a file to the home directory of a user
copy:
src: ./file1.txt
dest: ~/file1.txt
owner: setup
mode: 0766
Ansible module return values
- stdout or stdout_lines: This is the variable that contains the standard output of commands executed using an execution module such as raw, command, shell, or win_shell. The stdout_lines have the same value and string as stdout but they have a more organized outputāa human-readable text divided into lines.
- stderr or stderr_lines: This has the same output source as stdout, but this is the error message output. If the command executed returns an error message, it will be stored in this variable. The stderr_lines also have the same output string as stderr but are more organized into lines.
- changed: This is the return value that indicates the status of the task or action if the task has made a change to the target host. It will contain a Boolean value of True or False.
- failed: This is another status update return value that indicates whether the task or action has failed or not. It is also a Boolean v...