Categories

Category cover

Automation
155 posts

Category cover

Learning paths
119 posts

Category cover

CISO
22 posts

Category cover

Security
20 posts

Category cover

Notes
19 posts

Category cover

Personal Security
18 posts

Category cover

Infrastructure
12 posts

Category cover

OT/ICS
5 posts

Category cover

Books
3 posts

Category cover

UNetLab
3 posts

Category cover

Write-up
3 posts

Category cover

OSInt
2 posts

Category cover

My life
1 posts

Handling errors in Ansible playbooks

Andrea Dainese
October 09, 2024
Post cover

When developing playbooks, it’s often necessary to modify Ansible’s default behavior in case of errors.

Here are three common scenarios:

  • When a task should only run in a specific mode
  • When a task should never report changes
  • When a task should fail under certain conditions

Additionally, we’ll explore three scenarios that are useful to know but rarely encountered in practice.

Running Tasks in a specific mode

You can enforce a task to run only in a specific mode. For instance, the following task runs only in check mode (-C):

However, this doesn’t change the task’s behavior, only when it is executed. In check mode, commands that can alter the system are not executed. Each module handles check mode differently.

Continue reading the post on Patreon .