在playbook中使用“delegate_to”指示任务在远程主机上以不同的SSH用户身份运行。
示例代码:
name: Run command as userA command: whoami delegate_to: 10.0.0.1 remote_user: userA
name: Run command as userB command: whoami delegate_to: 10.0.0.1 remote_user: userB
上一篇:ansible执行脚本时出现的奇怪行为
下一篇:Ansible执行任务时出现“致命错误:[test1]:FAILED!=>{"msg":"超时(62秒)等待提升权限提示:"}”的错误信息。