Ansible Series Tutorial (3): Introduction to Playbooks and YAML Basics

Ansible Series Tutorial (3): Introduction to Playbooks and YAML Basics

Introduction in one sentence: Playbooks are the core of Ansible, describing tasks using YAML, making automation repeatable and maintainable. 1. What is a Playbook? A Playbook is like a “script” for Ansible, defining a series of tasks to be executed in a YAML file and specifying on which hosts to execute them. Its characteristics are: … Read more

Ansible Series Tutorial (Part 2): Ad-hoc Commands and Common Modules

Ansible Series Tutorial (Part 2): Ad-hoc Commands and Common Modules

Introduction in one sentence: Ad-hoc commands are Ansible’s “quick knife”, allowing you to manage servers in bulk with a single command in the command line. 1. What are Ad-hoc Commands? In Ansible, there are two main execution methods: 1.Ad-hoc commands: Execute a single task directly in the command line, suitable for temporary bulk operations. 2.Playbook: … Read more

Ansible Playbook in Action: One Script Managing 1000 Servers, Boosting Operational Efficiency by 10 Times

Ansible Playbook in Action: One Script Managing 1000 Servers, Boosting Operational Efficiency by 10 Times

Linux Cloud Computing | Daily Practice | Practical Tools | Career Development 💥 “Manually SSH logging into 100 servers to change configurations, working overtime until dawn and still missing some?” “Inconsistent environments across different machines, crashing upon deployment?” “Mistyping commands during late-night deployments and being held accountable?” These operational “nightmare scenarios” are essentially due to … Read more

Best Practices for Ansible: Making Automated Operations More Elegant and Efficient

Best Practices for Ansible: Making Automated Operations More Elegant and Efficient

Best Practices for Ansible: Making Automated Operations More Elegant and Efficient > Master these tips to say goodbye to chaotic Playbooks Introduction: Why Do We Need Best Practices? Hello everyone, I believe many of you have experienced this when using Ansible: as you write your Playbook, it turns into a tangled mess, and two months … Read more

Ansible Playbook Grouping Plays with Block

Ansible Playbook Grouping Plays with Block

Ansible Playbook Grouping Plays with Block Playbooks can group plays using <span>block</span>, not only for grouping, but <span>block</span> can also handle task errors during the execution of the <span>block</span>. <span>block</span> handles errors in two ways: • <span>rescue</span>: This task will only execute if a task within the <span>block</span> returns a failed status. • <span>always</span>: This … Read more

Core Basics of Ansible Playbook: From YAML Syntax and File Structure to Core Elements

Core Basics of Ansible Playbook: From YAML Syntax and File Structure to Core Elements

Ansible Playbooks are written in YAML. They describe the entire process of automation in a human-readable language. This article will delve into the fundamental core of Playbooks, further mastering the clever uses of Ansible scripts. YAML Syntax 1. Indentation Rules <span>YAML</span> uses spaces for indentation to represent hierarchical relationships, which is its most basic syntax … Read more

Quick Start with Ansible for Automated Operations and Maintenance (Part 1)

Quick Start with Ansible for Automated Operations and Maintenance (Part 1)

First, my system is Ubuntu 24.04 LTS, operated as the root user;The first step is to install, then check the version, followed by generating keys and verifying; the commands in the screenshot can be typed manually, do not copy directly at the beginning;Next, a small script is used to distribute keys in bulk; the first … Read more

Ansible Playbook Task Import: From Basics to Advanced

Ansible Playbook Task Import: From Basics to Advanced

Ansible Playbook Task Import When using Playbooks, there may be some frequently used Plays. In this case, you can utilize the import method in Playbooks to reuse the same Play. The imported tasks serve as a task template (without the <span>hosts</span> and <span>tasks</span> fields, as shown in the example below). There are two modes for … Read more

Essential Software Installation with Ansible Playbook on CentOS 7

Essential Software Installation with Ansible Playbook on CentOS 7

—- name: Install common system packages hosts: all become: yes # Equivalent to -b vars: common_packages: – net-tools – vim – tree – htop – iftop – gcc – gcc-c++ – glibc – iotop – lrzsz – sl – wget – unzip – telnet – nmap – nc – psmisc – dos2unix – bash-completion – … Read more

Ansible Playbook Error Handling

Ansible Playbook Error Handling

Ansible Playbook Error Handling When an Ansible task returns a non-zero status code, the task execution fails and prints an error message. Ignore Errors <span>ignore_errors: true</span> can be used to ignore errors and continue execution. – name: Do not count this as a failure ansible.builtin.command: /bin/false ignore_errors: true <span>ignore_errors: true</span> can be set at the … Read more