ansible识别SSH用户ansible瓦尔
问题描述:
在一些ansible剧本我歌厅一个ansible识别SSH用户ansible瓦尔
rsync: mkdir "/var/www/xxx" failed: Permission denied
我需要检查什么是我ansible在目标虚拟机使用的用户。
如何使用debug:
行打印用户?
我寻找类似于$ id
unix命令来调试权限Pb。
答
Ansible将始终默认为当前用户(在shell中),并且如果要使用其他用户连接到远程计算机,则可以在您的剧本中使用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}}"