I have multiple host details under one group in my Ansible hosts file. Like below,
[web-server]
10.0.0.1 name=apache ansible_ssh_user=username
10.0.0.2 name=nginx ansible_ssh_user=username
My ansible playbook,
---
- hosts: web-server[0]
roles:
- role: apache
These details gets added dynamically in the hosts file and I have no control over the order of lines getting added under a group. Hence I can't use the logic web-server[0] or web-server[1]
I want to mention the host by filtering based on the "name" parameter in the playbook since name will be unique. Is there a way to do this, Kindly help.