At some point in Ansible 2.0.x, the ‘{{ansible_user}}’ variable would reflect the argument passed to ansible-playbook ‘-u’. It doesn’t appear to be doing this any more, and I can’t seem to find a way to obtain the value that was passed into ‘-u’. Is there a known way to do this?
My specific use-case is that when I create a new EC2 instance, I must wait for that instance to come online before I continue my playbook. I have been using a local_action which continually calls an ‘ssh’ client against the remote until I get a successful SSH login. I realize that most users would use a wait_for action, but that has 2 issues:
- If you don’t have direct network-level connectivity to the remote machine (eg, you SSH through a proxy)
- Even if port 22 is up, it doesn’t guarantee that the host is ready to be logged into (for example, a cloud-init script might need to run in order to allow you in)
I figure that the best way to test if the instance can be logged into is to actually login to the instance. I’m open to alternatives if you have them.
Regards,
Mike