when hostname ansible 1

when hostname ansible

# Use Special Variable inventory_hostname
when: inventory_hostname == 'your_inventory_name'

Here is what the above code is Doing:
1. We’re using the ‘hosts’ keyword to specify the host or group of hosts we want to run the task on.
2. We’re using the ‘when’ keyword to specify a condition that must be met for the task to run.
3. We’re using the ‘inventory_hostname’ variable to specify the hostname of the host we want to run the task on.

Similar Posts