How to switch the local connection user from root to another user

1,181 views
Skip to first unread message

Tony Chia

unread,
Nov 28, 2017, 5:21:42 PM11/28/17
to AWX Project
Here is my playbook

# test.yml
- name: localhost_test
  hosts: localhost
  gather_facts: false

  tasks:
  - name: Run ls
    shell: ls
    register: ls_result

I am using a local ansible.cfg with this setting

remote_user = tchia

when I run this on the command line, I can see it's using my user name
ansible-playbook -vvvv -i ./inventory test.yml   

Using module file /usr/lib/python2.7/site-packages/ansible/modules/commands/command.py
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: tchia
<localhost> EXEC /bin/sh -c 'echo ~ && sleep 0'

However when run the same playbook through AWX, it's not picking my my remote_user setting even though the awx log file show it's using my ansible.cfg

ansible-playbook 2.4.1.0
2
config file = /var/lib/awx/projects/perforce_test/ansible.cfg
3
configured module search path = [u'/var/lib/awx/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
......4

......
Using module_utils file /usr/lib/python2.7/site-packages/ansible/module_utils/pycompat24.py
28
Using module_utils file /usr/lib/python2.7/site-packages/ansible/module_utils/six/__init__.py
29
Using module file /usr/lib/python2.7/site-packages/ansible/modules/commands/command.py
30
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: root
31
<127.0.0.1> EXEC /bin/sh -c 'echo ~ && sleep 0'
32





Matthew Jones

unread,
Nov 29, 2017, 7:58:27 AM11/29/17
to Tony Chia, AWX Project
Did you try "ansible_user" ?

using "become" is another option which is probably more in line with what you want.

--
You received this message because you are subscribed to the Google Groups "AWX Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to awx-project+unsubscribe@googlegroups.com.
To post to this group, send email to awx-p...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/awx-project/7c396b90-dc41-49b7-9542-eb1e3e0f92bd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Matt Jones
Principal Software Engineer
Ansible Tower
Reply all
Reply to author
Forward
0 new messages