MOCs
- Overview
- Tips and Tricks
- Installation
- Basic Concepts
- Running Ad-Hoc Commands
- Playbooks
- Roles
- Variables and Facts
- Inventory
- Modules
- Ansible Galaxy
Overview
Ansible is an open-source automation tool, or platform, used for IT tasks such as configuration management, application deployment, intra-service orchestration, and provisioning. It uses no agents and no additional custom security infrastructure, making it easy to deploy.
Documentation
Base Documentation
Ansible Galaxy
Tips and Tricks
- Dry Run: Use the
--check
flag to perform a “dry run” of your playbook. - Tags: Use tags to run specific parts of your playbook.
- Vault: Use Ansible Vault to encrypt sensitive data. How to make a vault
Installation
Ansible can be installed on many systems with a simple command. For example, on a Debian-based system:
Basic Concepts
- Control Node: The machine from which Ansible is run.
- Managed Nodes: The servers being managed with Ansible.
- Inventory: A list of managed nodes.
- Modules: Units of scripts that Ansible executes.
- Tasks: Units of action in Ansible.
- Playbooks: YAML files for defining, running, and managing configurations and deployments to remote machines.
Running Ad-Hoc Commands
Ad-hoc commands are one-line commands that let you perform tasks quickly without writing a playbook. They are a great way to learn Ansible’s capabilities.
Playbooks
Playbooks are the heart of Ansible for running tasks. They describe the desired state of your systems using YAML.
- Sample Playbook:
Roles
Roles offer a framework for fully independent or interdependent collections of variables, tasks, files, templates, and modules.
Variables and Facts
Variables are used to deal with differences between systems, users, and other variables that can change between plays or executions.
Facts are global variables that Ansible collects from the managed nodes.
Inventory
The inventory is a list of nodes that can be managed by Ansible. It can specify information like IP address and domain name. A inventory can be made as an ini or a yaml
Modules
Modules are the units of work that Ansible executes. Each module has a particular use, from managing packages to executing shell commands.
Ansible Galaxy
Ansible Galaxy is a repository for sharing and reusing Ansible roles. Roles can be downloaded and used in your playbooks.