Common Ansible Modules
Six modules that do not belong to any one administration task but turn up in almost every real playbook. Each solves a problem the earlier guides work around: deriving a value, fetching something, talking to an API, waiting properly instead of sleeping, reading a remote file, and running something longer than the SSH timeout.
Plays and Playbooks Guide 17 of 45 Intermediate
- OSUbuntu 26.04 LTS
- ansible-core2.20.1
- Python3.14.4
- TimeAbout 17 min
set_fact creates a variable with very high precedence - above almost everything except role parameters and -e. That makes it powerful and easy to misuse: a set_fact in one role silently overrides a carefully placed default in another.
| Server Name | IP Address | OS | Roles | CPU | RAM | HDD |
|---|---|---|---|---|---|---|
| ANS-CTL01 | 192.168.0.36 | Ubuntu 26.04 LTS | Ansible Control Node | 2 Core | 3 GB | 50 GB |
| ANS-A01 | 192.168.0.37 | Ubuntu 26.04 LTS | Managed Node (group: web) | 2 Core | 3 GB | 50 GB |
This guide includes
Use this for the modules that belong to no particular task and turn up everywhere. This matters because six of them cover the gaps - computing a value, fetching a URL, calling an API, waiting, and outrunning the timeout.
- computing a variable with
set_fact - fetching with
get_url, and reading a remote file back withslurp - talking to an API with
uri - waiting for something to become ready with
wait_for - using
asyncfor work that runs longer than the timeout
Before you start
- A control node configured as shown in the first step, and a managed node with outbound internet access.
- The session downloads a small file to
/tmpon thewebhost and removes it.
-
The configuration this guide assumes
-
set_fact computes a variable
-
get_url and slurp
-
uri talks to an API
-
wait_for something to be ready
-
async for something longer than the timeout