In my dynamic ec2 inventory I have data similar to:
{
"_meta": {
"hostvars": {
"10.0.33.123": {
"ec2_tag_Name": "MyFirstHost",
}
"10.0.33.124": {
"ec2_tag_Name": "MySecondHost",
}
}
}
}
How do I make the equivallent of this task work properly in ansible?
- hostname: "{{ hostvars[ {{ ansible_eth0['ipv4']['address'] }} ]['ec2_tag_Name'] }}"
So that the hostname is set correctly on both hosts:
[email protected]:/# hostname
MyFirstHost
[email protected]:/# hostname
MySecondHost