1

so I am getting ansible setup and have a host configuration successfully setup via my ansible_hosts file:

104.236.59.171  ansible_connection=ssh  ansible_user=root

checking the configuration status of the hosts I get:

104.236.59.171 | success >> { "var": { "hostvars['104.236.xx.xxx']": { "ansible_connection": "ssh", "ansible_user": "root", "group_names": [ "ungrouped" ], "inventory_hostname": "104.236.xx.xxx", "inventory_hostname_short": "104" } } }

However, the user/name on my local machine takes precedence over the ansible_user variable which needs to be used for successful login.

I can override this with the -u option in my ansible commands, but when I have more than one different users on multiple server instances and I am iterating over all of them, that will not be an option.

How do I go about overriding the default user obtained from my local machine?

Thanks for any help!

2
  • please show your ansible code.
    – c4f4t0r
    Dec 10, 2015 at 0:13
  • Hey, sorry for the slow response. Shown!
    – ambe5960
    Dec 11, 2015 at 22:32

1 Answer 1

1

Check the Ansible documentation on Variable Precedence.

If you provide ansible_user variable with the -u parameter it will always overwrite every other variable definition.

As inventory vars is nearly at the top of the linked list you need to check for variable definition on the other levels. I would check with grep for other variable definitions and remove those.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .