In certain scenarios, you may need to retrieve data from a cloud provider or perform complex calculations, which can be time-consuming. Let’s assume you use an API for launching a virtual machine, and then you would like to reuse data and share among other roles. We assume, in the beginning, we don’t know the IP address of the machine. Once we know the IP, we want to launch configuring only one machine. For different reasons. It might be the speeding up of the execution and the desire not to waste time. 

Example 1:

YAML

 

– name: Configure frontends
hosts: frontends
gather_facts: no
roles:
– Create users
– Setup sshd
– name: Configure backends
hosts: backends
gather_facts: no
roles:
– Create users
– Setup sshd

Leave a Reply

Your email address will not be published. Required fields are marked *