ansible在ansible VAR中标识ssh用户

ansible在ansible VAR中标识ssh用户,ansible,Ansible,在一些易懂的脚本中,我得到了一个 rsync: mkdir "/var/www/xxx" failed: Permission denied 我需要检查我的ansible在目标VM中使用的用户是什么 如何使用debug:行打印用户 我寻找类似于$idunix命令的东西来调试权限Pb。Ansible将始终默认为当前用户(在shell中),如果您想使用其他用户连接到远程计算机,可以在Ansible playbook中使用远程用户 有关更多详细信息,请参阅 如果要运行shell命令并捕获输出:

在一些易懂的脚本中,我得到了一个

rsync: mkdir "/var/www/xxx" failed: Permission denied
我需要检查我的ansible在目标VM中使用的用户是什么

如何使用
debug:
行打印用户


我寻找类似于
$id
unix命令的东西来调试权限Pb。

Ansible将始终默认为当前用户(在shell中),如果您想使用其他用户连接到远程计算机,可以在Ansible playbook中使用远程用户

有关更多详细信息,请参阅

如果要运行shell命令并捕获输出:

  - name: "Run a shell command"
    shell: /usr/bin/id
    register: result

  - name: Print the value of result
    debug: var=result

  - name: Print the user id using the ansible_user_id fact
    debug: msg="{{ansible_user_id}}"