Hi, I have had twice now the use case of needing to access host vars of a specific host, without knowing the inventory hostname.
I would like to suggest to be able to read the value of the --limit parameter from inside a playbook.
Maybe something like an ansible_limit magic variable, which has as value an array of the “:” (colon) separated parts.
Then one could use jinja2 tests to figure out the target-host from that.
The use case for this is a playbook to configure a development environment for a specific developer, without having to edit any files at all, so the target host needs to be supplied as a parameter.
At the same time, I would like to avoid --extra_vars “target_host=”, because right now, I need both:
ansible-playbook setup-and-deploy-development -i inventory/vsphere --limit my-developer-vm.example.com:localhost --extra-vars “target_host=my-developer-vm.example.com”
I know in this case I could get rid of the “–limit” and put “{{ target_host }}” everywhere, but like I said, would like to avoid that…