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:
---
- include: base.yml
- hosts: all
sudo: no
tasks:
- name: get value of current user
action: debug msg="Value of ansible_env['HOME'] is
{{ansible_env['HOME']}}"
- name: get home of current user
action: debug msg="Value of ansible_env['USER'] is
{{ansible_env['USER']}}"
And base.yml (stripped down) looks like this:
---
- hosts: all
When including the (empty) base.yml file the output looks like this:
TASK: [get value of current user]
*********************************************
<127.0.0.1> ESTABLISH CONNECTION FOR USER: vagrant
ok: [default] => {
"msg": "Value of ansible_env['HOME'] is /root"
}
TASK: [get home of current user]
**********************************************
<127.0.0.1> ESTABLISH CONNECTION FOR USER: vagrant
ok: [default] => {
"msg": "Value of ansible_env['USER'] is root"
}
That's not what I wanted, I set sudo = no in the docker.yml.
Now I remove the inclusion of base.yml, run again, and I get correct output.
TASK: [get value of current user]
*********************************************
<127.0.0.1> ESTABLISH CONNECTION FOR USER: vagrant
ok: [default] => {
"msg": "Value of ansible_env['HOME'] is /home/vagrant"
}
TASK: [get home of current user]
**********************************************
<127.0.0.1> ESTABLISH CONNECTION FOR USER: vagrant
ok: [default] => {
"msg": "Value of ansible_env['USER'] is vagrant"
}
So the act of including another file seems to force ansible to execute
everything as root.
My goal here is to try and create a disposable development environment that
can be booted and up and running quickly on OSX.
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.