-
Notifications
You must be signed in to change notification settings - Fork 23.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ansible 2.0.0.2: Ansible doesn't respect the “-u” switch #14268
Comments
@bfqrst I am trying to reproduce this on my laptop (v2.0.0.2), and for me it seems to work out fine.
Only when I deliberately override the SSH user in the inventory I can see the same behaviour you experience ?
To rule out inventory-related causes, I created a similar inventory as you:
To rule out the
The error is obviously to be expected :-) Is there something you could have done differently ? |
Hi @dagwieers , thanks for investigating. I think I got something. I omitted the upper part of my inventory for brevity and because I thought it has no relevance, but it turns out it is the interesting part. Have a look at my updated inventory:
As you can see there are two distinct sections but they are pointing to the same IP. Now Ansible 1.9.4 seems to use the latter, whereas Ansible 2 uses the former and subsequently uses root as user . Maybe a parsing issue of some sort? I confirmed this behavior using two separate virtualenvs. Let me apologize for omitting crucial parts of my setup. I understand that in order to debug stuff you need to have the exact setup. My bad. Thanks EDIT: Just realized in Ansible 1.9.4 you need to actually use ansible_ssh_user... After that the results are consistent between Ansible 1 and Ansible 2 in the fact that both of the times the |
@bfqrst Great. Because that is what I was expecting. The names used in the inventory is the key in a dictionary. So everything you put in there as host-specific variables will be merged into one big dictionary. That means that in some conflicting cases variables are superseded by other values. You can prevent this by using different names for the same host (e.g. using IP address and hostname, or an alias or DNS-alias) and in that case you can still do what you like to do. |
Thanks, I will keep that in mind. I must admit that usually you don't have duplicate entries in your inventory. Using this like I did is a kind of an edge case. But then again, I would imagine that Raspberry PI et al users do trip over this. The reason is as obvious as it is simple. You have a PI which usually gets assigned the same IP from the home router. Then you fiddle around with different OSes. You have different SD cards with Raspbian, Archlinux, HyprIoT, OpenELEC, OSMC, you name it... Out of the box you may or may not know what the hostname will be, but you know the IP, right? At least that's how my inventory file ended up like it did. In terms of the title of this issue, I think we all agree that Ansible does respect the I'd imagine that a mention of these edge cases in the documentation would be helpful? Anyway, I appreciate you guys looking into it. Thanks for the insight. Cheers |
Closing as per above, thanks @dagwieers @bfqrst I would have actually expected this to work the same across both versions, a host should get the variables from all the groups it is defined in, this looks like a bug in 1.9 for not picking up the variable. Making a note to fix this in possible 1.9.5 release. |
@bcoca And that is the case, but ansible_user is not effective on v1, while it is on v2. So everything is fine, no note needed ;-) |
ah, DUH!, it would work the same if it where removed note, this all works as expected. |
This inventory file works for me. (Ansible 2.0.0.2)
Thanks for helping @dagwieers @bcoca |
@bfqrst That is what I meant ! Well done. |
BUG REPORT
I'm probing a freshly installed Archlinux installation on a Raspberry PI 2 like so:
ansible -i PI2 arch -m setup -c paramiko -k -u alarm -vvvv
This reads to me: Fire the setup module against the IP connecting with the user "alarm" asking for the password of this specific user. However the user that eventually attempts to connect is "root".
Here's the debug response:
The inventory looks like this:
The expected result, as version 1.9.4 delivers is:
The control machine is a MBA on 10.11.3. The command was run against a Raspberry PI 2 running Archlinux.
Cheers
Ralph
The text was updated successfully, but these errors were encountered: