我想在用户下的机器上运行local_action
。但是,该命令失败,因为它是通过sudo -u root
<localhost> EXEC /bin/sh -c 'sudo -H -S -n -u root /bin/sh -c '"'"'echo BECOME-SUCCESS-rporvrakuzytzohimeygjirtbcocqbsj ;
/usr/bin/python /home/papanito/.ansible/tmp/ansible-tmp-1579883794.404003-255151921346952/AnsiballZ_command.py'"'"' && sleep 0'
可能剧本确实定义了become: false
,所以我不明白为什么用-u root
执行命令
- hosts: localhost
become: false
connection: local
gather_facts: no
vars:
- resources_path: "{{playbook_dir}}/../resources"
tasks:
- name: Execute the command in remote shell; stdout goes to the specified file on the remote.
command: rke up --config {{resources_path}}/k8s/rke/dev-cluster.yml
delegate_to: localhost
我也尝试指定remote_user: papanito
,但这也无济于事-我也不会期望它正常工作,因为remote_user
是用于ssh连接的那个,而这里有一个{{1 }}连接。
local
也不能解决问题
become_user