在一些ansible脚本中,我得到了一个
rsync: mkdir "/var/www/xxx" failed: Permission denied
我需要检查Ansible在目标VM中使用的用户是什么。
如何用debug:
一行打印用户?
我正在寻找类似$ id
unix命令的命令来调试权限Pb。
Ansible将始终默认为当前用户(在Shell中),并且如果您要使用其他用户连接到远程计算机,则可以在Ansible剧本中使用remote_user。
有关更多详细信息,请参见:http : //docs.ansible.com/ansible/intro_configuration.html#remote-user。
如果要运行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}}"
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句