Hi,
I have a playbook in which I need to run tasks with different remote users.
This is what the main playlist looks like:
`
#Configure and install all we need
- hosts: ec2hosts
gather_facts: true
remote_user: ec2-user
sudo: yes
roles: - common
`
And all tasks that have to be run as ec2-user work great.
However, I need to run some of the tasks with a different user, named rails. In order to do this, I specify the remote_user parameter in the task, but for some reason, the task is still executed as ec2-user:
`
- name: rbenv // basic test
shell: ls -lah
remote_user: rails
sudo: no
tags: rbenv
`
Resulting in this:
`
TASK: [common | rbenv // basic test] ******************************************
<54.73.67.35> ESTABLISH CONNECTION FOR USER: ec2-user
<54.73.67.35> REMOTE_MODULE command ls -lah #USE_SHELL
<54.73.67.35> EXEC [‘ssh’, ‘-C’, ‘-tt’, ‘-vvv’, ‘-o’, ‘ControlMaster=auto’, ‘-o’, ‘ControlPersist=60s’, ‘-o’, ‘ControlPath=/Users/bernatrafalesimulet/.ansible/cp/ansible-ssh-%h-%p-%r’, ‘-o’, ‘KbdInteractiveAuthentication=no’, ‘-o’, ‘PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey’, ‘-o’, ‘PasswordAuthentication=no’, ‘-o’, ‘User=ec2-user’, ‘-o’, ‘ConnectTimeout=10’, u’54.73.67.35’, “/bin/sh -c ‘mkdir -p $HOME/.ansible/tmp/ansible-tmp-1395246103.49-134656247335216 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1395246103.49-134656247335216 && echo $HOME/.ansible/tmp/ansible-tmp-1395246103.49-134656247335216’”]
<54.73.67.35> PUT /var/folders/mg/1txhtf2d6c1fx4mzmvp9zlbc0000gn/T/tmpcdqUUp TO /home/ec2-user/.ansible/tmp/ansible-tmp-1395246103.49-134656247335216/command
<54.73.67.35> EXEC [‘ssh’, ‘-C’, ‘-tt’, ‘-vvv’, ‘-o’, ‘ControlMaster=auto’, ‘-o’, ‘ControlPersist=60s’, ‘-o’, ‘ControlPath=/Users/bernatrafalesimulet/.ansible/cp/ansible-ssh-%h-%p-%r’, ‘-o’, ‘KbdInteractiveAuthentication=no’, ‘-o’, ‘PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey’, ‘-o’, ‘PasswordAuthentication=no’, ‘-o’, ‘User=ec2-user’, ‘-o’, ‘ConnectTimeout=10’, u’54.73.67.35’, “/bin/sh -c ‘/usr/bin/python /home/ec2-user/.ansible/tmp/ansible-tmp-1395246103.49-134656247335216/command; rm -rf /home/ec2-user/.ansible/tmp/ansible-tmp-1395246103.49-134656247335216/ >/dev/null 2>&1’”]
changed: [54.73.67.35] => {“changed”: true, “cmd”: "ls -lah ", “delta”: “0:00:00.009791”, “end”: “2014-03-19 16:21:53.695525”, “item”: “”, “rc”: 0, “start”: “2014-03-19 16:21:53.685734”, “stderr”: “”, “stdout”: “total 28K\ndrwx------ 4 ec2-user ec2-user 4.0K Mar 19 16:21 .\ndrwxr-xr-x 4 root root 4.0K Mar 19 16:21 …\ndrwxrwxr-x 3 ec2-user ec2-user 4.0K Mar 19 16:21 .ansible\n-rw-r–r-- 1 ec2-user ec2-user 18 Sep 4 2013 .bash_logout\n-rw-r–r-- 1 ec2-user ec2-user 176 Sep 4 2013 .bash_profile\n-rw-r–r-- 1 ec2-user ec2-user 124 Sep 4 2013 .bashrc\ndrwx------ 2 ec2-user ec2-user 4.0K Feb 17 10:29 .ssh”}
`
Which shows me the list of files of the ec2-user home folder.
Is there any particular reason why I can’t override the remote_user, or what am I doing wrong?
Thanks