Skip to content

Instantly share code, notes, and snippets.

@hagbarddenstore
Last active November 11, 2015 12:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hagbarddenstore/2b5b5ef8e18540fd5172 to your computer and use it in GitHub Desktop.
Save hagbarddenstore/2b5b5ef8e18540fd5172 to your computer and use it in GitHub Desktop.
Ansible does funky stuff when sudo: yes is added to the playbook rather than the task. I run this command: ansible-playbook -i inventory.ini playbook.yml -vvv
$ ansible --version
ansible 1.9.0.1
configured module search path = None
host ansible_ssh_host=10.10.0.222 ansible_ssh_user=ubuntu
PLAY [all] ********************************************************************
GATHERING FACTS ***************************************************************
<10.10.0.222> ESTABLISH CONNECTION FOR USER: ubuntu
<10.10.0.222> REMOTE_MODULE setup
<10.10.0.222> EXEC ssh -C -tt -v -o ControlMaster=auto -o ControlPersist=60s -o ControlPath="/Users/me/.ansible/cp/ansible-ssh-%h-%p-%r" -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ubuntu -o ConnectTimeout=10 10.10.0.222 /bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1447245790.62-12324257132658 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1447245790.62-12324257132658 && echo $HOME/.ansible/tmp/ansible-tmp-1447245790.62-12324257132658'
<10.10.0.222> PUT /var/folders/mp/9r2fm4_j56j8wmz6_9w3c0zm0000gn/T/tmpVWQrZG TO /home/ubuntu/.ansible/tmp/ansible-tmp-1447245790.62-12324257132658/setup
<10.10.0.222> EXEC ssh -C -tt -v -o ControlMaster=auto -o ControlPersist=60s -o ControlPath="/Users/me/.ansible/cp/ansible-ssh-%h-%p-%r" -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ubuntu -o ConnectTimeout=10 10.10.0.222 /bin/sh -c 'sudo -k && sudo -H -S -p "[sudo via ansible, key=redacted] password: " -u root /bin/sh -c '"'"'echo BECOME-SUCCESS-redacted; LANG=en_US.UTF-8 LC_CTYPE=en_US.UTF-8 /usr/bin/python /home/ubuntu/.ansible/tmp/ansible-tmp-1447245790.62-12324257132658/setup; rm -rf /home/ubuntu/.ansible/tmp/ansible-tmp-1447245790.62-12324257132658/ >/dev/null 2>&1'"'"''
ok: [host]
TASK: [print ansible_user_dir] ************************************************
<10.10.0.222> ESTABLISH CONNECTION FOR USER: ubuntu
ok: [host] => {
"var": {
"ansible_user_dir": "/root"
}
}
PLAY [all] ********************************************************************
GATHERING FACTS ***************************************************************
<10.10.0.222> ESTABLISH CONNECTION FOR USER: ubuntu
<10.10.0.222> REMOTE_MODULE setup
<10.10.0.222> EXEC ssh -C -tt -v -o ControlMaster=auto -o ControlPersist=60s -o ControlPath="/Users/me/.ansible/cp/ansible-ssh-%h-%p-%r" -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ubuntu -o ConnectTimeout=10 10.10.0.222 /bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1447245793.94-5782295987535 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1447245793.94-5782295987535 && echo $HOME/.ansible/tmp/ansible-tmp-1447245793.94-5782295987535'
<10.10.0.222> PUT /var/folders/mp/9r2fm4_j56j8wmz6_9w3c0zm0000gn/T/tmp_rOXR8 TO /home/ubuntu/.ansible/tmp/ansible-tmp-1447245793.94-5782295987535/setup
<10.10.0.222> EXEC ssh -C -tt -v -o ControlMaster=auto -o ControlPersist=60s -o ControlPath="/Users/me/.ansible/cp/ansible-ssh-%h-%p-%r" -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ubuntu -o ConnectTimeout=10 10.10.0.222 /bin/sh -c 'LANG=en_US.UTF-8 LC_CTYPE=en_US.UTF-8 /usr/bin/python /home/ubuntu/.ansible/tmp/ansible-tmp-1447245793.94-5782295987535/setup; rm -rf /home/ubuntu/.ansible/tmp/ansible-tmp-1447245793.94-5782295987535/ >/dev/null 2>&1'
ok: [host]
TASK: [print ansible_user_dir] ************************************************
<10.10.0.222> ESTABLISH CONNECTION FOR USER: ubuntu
ok: [host] => {
"var": {
"ansible_user_dir": "/home/ubuntu"
}
}
PLAY [all] ********************************************************************
GATHERING FACTS ***************************************************************
<10.10.0.222> ESTABLISH CONNECTION FOR USER: ubuntu
<10.10.0.222> REMOTE_MODULE setup
<10.10.0.222> EXEC ssh -C -tt -v -o ControlMaster=auto -o ControlPersist=60s -o ControlPath="/Users/me/.ansible/cp/ansible-ssh-%h-%p-%r" -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ubuntu -o ConnectTimeout=10 10.10.0.222 /bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1447245795.26-140579001865936 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1447245795.26-140579001865936 && echo $HOME/.ansible/tmp/ansible-tmp-1447245795.26-140579001865936'
<10.10.0.222> PUT /var/folders/mp/9r2fm4_j56j8wmz6_9w3c0zm0000gn/T/tmp_d9GZK TO /home/ubuntu/.ansible/tmp/ansible-tmp-1447245795.26-140579001865936/setup
<10.10.0.222> EXEC ssh -C -tt -v -o ControlMaster=auto -o ControlPersist=60s -o ControlPath="/Users/me/.ansible/cp/ansible-ssh-%h-%p-%r" -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ubuntu -o ConnectTimeout=10 10.10.0.222 /bin/sh -c 'LANG=en_US.UTF-8 LC_CTYPE=en_US.UTF-8 /usr/bin/python /home/ubuntu/.ansible/tmp/ansible-tmp-1447245795.26-140579001865936/setup; rm -rf /home/ubuntu/.ansible/tmp/ansible-tmp-1447245795.26-140579001865936/ >/dev/null 2>&1'
ok: [host]
TASK: [print ansible_user_dir] ************************************************
<10.10.0.222> ESTABLISH CONNECTION FOR USER: ubuntu
ok: [host] => {
"var": {
"ansible_user_dir": "/home/ubuntu"
}
}
PLAY RECAP ********************************************************************
host : ok=6 changed=0 unreachable=0 failed=0
---
- hosts: all
sudo: yes
tasks:
- name: print ansible_user_dir
debug:
var=ansible_user_dir
- hosts: all
tasks:
- name: print ansible_user_dir
debug:
var=ansible_user_dir
sudo: yes
- hosts: all
sudo: no
tasks:
- name: print ansible_user_dir
debug:
var=ansible_user_dir
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment