Operations 7 min read

Master Ansible: Architecture, Workflow, and Essential Commands Explained

This article introduces Ansible's model‑driven architecture, explains how it connects to and manages hosts, and details the seven core commands with usage examples, helping readers understand and apply Ansible for automated configuration and deployment tasks.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
Master Ansible: Architecture, Workflow, and Essential Commands Explained

Ansible is a model‑driven configuration manager that supports multi‑node deployment and remote task execution, using SSH by default and requiring no additional software on managed nodes; it can be extended with various programming languages.

1. Ansible Basic Architecture

Ansible architecture diagram
Ansible architecture diagram

The diagram shows that Ansible consists of the following components:

Core: Ansible itself

Core Modules: modules shipped with Ansible

Custom Modules: user‑added modules for extra functionality

Plugins: extensions that supplement module capabilities

Playbooks: task configuration files that define multiple tasks for automated execution

Connection Plugins: enable connections to hosts via SSH and other methods

Host Inventory: definitions of the hosts managed by Ansible

2. Ansible Working Principle

Ansible workflow diagram 1
Ansible workflow diagram 1
Ansible workflow diagram 2
Ansible workflow diagram 2

Key points from the diagrams:

The control node can connect to managed hosts via local, SSH, or ZeroMQ, with SSH being the default (connection plugins).

Hosts can be grouped in the inventory by application type or other criteria; single‑module, single‑command batch execution is called ad‑hoc.

Playbooks allow multiple tasks to be combined into a single workflow, such as web service deployment or database backup, effectively chaining ad‑hoc operations.

3. Seven Essential Ansible Commands

After installing Ansible, you have the following seven commands. Below are their usage sections; detailed options can be obtained with the -h flag.

1. ansible

[root@localhost ~]# ansible -h
Usage: ansible [options]

The ansible command runs ad‑hoc commands on target hosts. By default it uses the command module unless another module is specified.

[[email protected] ~]# ansible 192.168.0.102 -a 'date'
192.168.0.102 | success | rc=0 >>
Tue May 12 22:57:24 CST 2015

Default module can be changed in ansible.cfg.

2. ansible-doc

ansible-doc -h
Usage: ansible-doc [options] [module...]

Shows module documentation. Common options are -l to list all modules and -s to display a module's syntax.

# ansible-doc -l
# ansible-doc -s command

3. ansible-galaxy

ansible-galaxy -h
Usage: ansible-galaxy [init|info|install|list|remove] [--help] [options] ...

The command downloads third‑party roles from Ansible Galaxy , similar to yum or pip.

[root@localhost ~]# ansible-galaxy install aeriscloud.docker
- downloading role 'docker', owned by aeriscloud
- downloading role from https://github.com/AerisCloud/ansible-docker/archive/v1.0.0.tar.gz
- extracting aeriscloud.docker to /etc/ansible/roles/aeriscloud.docker
- aeriscloud.docker was installed successfully

4. ansible-lint

Checks playbook syntax: ansible-lint playbook.yml.

5. ansible-playbook

The most frequently used command; it reads a playbook file and executes the defined tasks.

6. ansible-pull

Runs Ansible in pull mode, the opposite of the default push mode, useful for configuring a large number of machines or machines without network access.

7. ansible-vault

Encrypts and decrypts sensitive data in files. Encrypted files can be used in playbooks, requiring the --ask-vault-pass option at execution time.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Configuration ManagementPlaybooks
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.