# possible bug with users

**URL:** <https://forum.ansible.com/t/possible-bug-with-users/14249>\
**Category:** Ansible Project\
**Created:** [January 2, 2014, 11:05am UTC](https://forum.ansible.com/t/possible-bug-with-users/14249 "2014-01-02T11:05:11Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![bryan\_hunt1](https://avatars.discourse-cdn.com/v4/letter/b/ed8c4c/32.png) [@bryan\_hunt1](https://forum.ansible.com/u/bryan_hunt1)\
**Post date:** [January 2, 2014, 11:05am UTC](https://forum.ansible.com/t/possible-bug-with-users/14249/1 "2014-01-02T11:05:11Z")

</div>

Hi there,

I’m running via Vagrant, so everything should be executing by default as vagrant user.

My configuration looks like this

config.vm.provision “ansible” do |ansible|  
ansible.playbook = “…/playbooks/docker.yml”  
ansible.sudo = true  
ansible.host\_key\_checking = false  
ansible.verbose = ‘vvvv’  
end

The docker.yml file (stripped down) looks like this:

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [January 2, 2014, 9:50pm UTC](https://forum.ansible.com/t/possible-bug-with-users/14249/2 "2014-01-02T21:50:48Z")

</div>

I’m not sure where you are saying a bug might lie, but you’ve only shown _PART_ of the play above, so I can’t tell what you are doing with it.

If there was a bug with our user handling, I’m pretty positive we would have heard about it 1000x over, but this list is for helping people out with questions.

I would only ask that people not first assume they have found a bug, but instead ask for help with a problem.

---

<div class="post-metadata">

**Author:** ![Adam\_Morris](https://avatars.discourse-cdn.com/v4/letter/a/ecae2f/32.png) [@Adam\_Morris](https://forum.ansible.com/u/Adam_Morris)\
**Post date:** [January 3, 2014, 4:10am UTC](https://forum.ansible.com/t/possible-bug-with-users/14249/3 "2014-01-03T04:10:14Z")

</div>

I am no expert, but I think that what he is saying is that when he includes base.yml then his setting of sudo:no in the file that includes base.yml is overridden.

Thus his “possible bug with users” really translates as “possible bug with sudo being used when I don’t expect it”

It’s really to do with sudo usage and nothing to do with the user module (which was what I expected when I read the title).

I hope that this helps,

Adam

---

<div class="post-metadata">

**Author:** ![bryan\_hunt1](https://avatars.discourse-cdn.com/v4/letter/b/ed8c4c/32.png) [@bryan\_hunt1](https://forum.ansible.com/u/bryan_hunt1)\
**Post date:** [January 3, 2014, 10:00am UTC](https://forum.ansible.com/t/possible-bug-with-users/14249/4 "2014-01-03T10:00:18Z")

</div>

Yes, to clarify, “possible bug with sudo being used when I don’t expect it”.

I deleted everything but the code needed to demonstrate the (possible) bug.

That code, when run - as is, demonstrates the problem.

It is part of a larger effort to create an Ansible config to provision a Vagrant box, install a couple of packages, and check out a couple of projects from github R/W.

The reason I don’t want to hard code the vagrant username is that I want to use the playbooks to be independent of Vagrant, I want to reuse it on Amazon, Linode, etc.

The even larger goal is to create and share a couple of useful roles.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [January 3, 2014, 1:00pm UTC](https://forum.ansible.com/t/possible-bug-with-users/14249/5 "2014-01-03T13:00:20Z")

</div>

“That code, when run - as is, demonstrates the problem.”

That’s not what I wanted, I set sudo = no in the docker.yml.

There’s no variable called “sudo” you can just drop in a YAML file, which implies we need to see the full uncensored playbook to tell you what would need to be changed.

Can you perhaps share this with everyone on github or gist, etc?

---

<div class="post-metadata">

**Author:** ![bryan\_hunt1](https://avatars.discourse-cdn.com/v4/letter/b/ed8c4c/32.png) [@bryan\_hunt1](https://forum.ansible.com/u/bryan_hunt1)\
**Post date:** [January 3, 2014, 2:29pm UTC](https://forum.ansible.com/t/possible-bug-with-users/14249/6 "2014-01-03T14:29:35Z")

</div>

Hi Michael,

I’ve put a POC in [git@github.com](mailto:git@github.com):picsolvebryan/ansible-vagrant-poc.git

I’ve got it pinned down now.

What is actually happening, I’m guessing is the variable ansible\_env is only getting set once per execution.

I was using {{ansible\_env[‘HOME’]}} to figure out the correct location into which I would put a $HOME/.ssh/known\_hosts file.

Using ansible\_env was unreliable. If I included something that ran using sudo, it would set ansible\_env[‘HOME’] to /root for the entire execution rather then regenerate it per-playbook.

My kludge is to get those vars from system utils and register them for use by tasks defined further down the file. Like so:

- name: Get value of unpriv user  
shell: /usr/bin/id -un  
register: effective\_username

# And this here, gives the correct homedir

- name: Get homedir of unpriv user  
shell: “echo $HOME”  
register: effective\_homedir

---

<div class="post-metadata">

**Author:** ![Brian\_Coca1](https://avatars.discourse-cdn.com/v4/letter/b/278dde/32.png) [@Brian\_Coca1](https://forum.ansible.com/u/Brian_Coca1)\
**Post date:** [January 3, 2014, 2:55pm UTC](https://forum.ansible.com/t/possible-bug-with-users/14249/7 "2014-01-03T14:55:28Z")

</div>

ansible\_env gets set when facts are gathered and of course user variables  
depend on which user was used to gather those facts.

---

<div class="post-metadata">

**Author:** ![bryan\_hunt1](https://avatars.discourse-cdn.com/v4/letter/b/ed8c4c/32.png) [@bryan\_hunt1](https://forum.ansible.com/u/bryan_hunt1)\
**Post date:** [January 3, 2014, 3:00pm UTC](https://forum.ansible.com/t/possible-bug-with-users/14249/8 "2014-01-03T15:00:22Z")

</div>

Yes. Well surmised. Is there any way to re-trigger the gathering inside a playbook?

---

<div class="post-metadata">

**Author:** ![bryan\_hunt1](https://avatars.discourse-cdn.com/v4/letter/b/ed8c4c/32.png) [@bryan\_hunt1](https://forum.ansible.com/u/bryan_hunt1)\
**Post date:** [January 3, 2014, 3:04pm UTC](https://forum.ansible.com/t/possible-bug-with-users/14249/9 "2014-01-03T15:04:33Z")

</div>

I think this has been answered in a previous post.

[https://groups.google.com/forum/#!searchin/ansible-project/$20facts$20gathered/ansible-project/AGuHOnCgpc4/XIKaAnP3I-UJ](https://groups.google.com/forum/#!searchin/ansible-project/$20facts$20gathered/ansible-project/AGuHOnCgpc4/XIKaAnP3I-UJ)

re-run the setup module, to get updated ansible\_env

tasks:

- action: setup

Thanks guys!
