Hello,
How to filter ans extract variable in static inventory.
Example:
[webserver]
10.10.10.10
20.20.20.20
Hello,
How to filter ans extract variable in static inventory.
Example:
[webserver]
10.10.10.10
20.20.20.20
You can simply use {{inventory_hostname}} to get the host name of the host
Hello,
How to filter ans extract variable in static inventory.
Example:
[webserver]
10.10.10.10
20.20.20.20
--------------------------
i would to extract each host alone and put him in variable for use in playbook.
First entry:
groups['webserver'][0]
Second entry:
groups['webserver'][1]
Use in a task
debug:
msg: {{ groups['webserver'][0] }}
Regards
Racke
{{hostvars [inventory_hostname][“environment”]}}
Typo
{{hostvars [inventory_hostname][“environment”][0]}}
Thank you for your answer,
exactly, il like to make a loop for the role , each time he copie each host in file
example:
turn 1 for loop: copie 10.10.10.10. in file and send it to distant server
turn 2 for loop: copie 20.20.20.20. in file and send it to distant server
Thank you