Ansible proxy_to如何设置用于连接目标的用户?

Rok*_*okL 7 ansible ansible-2.x

我有一个Ansible(2.1.1。)库存:

build_machine ansible_host=localhost ansible_connection=local
staging_machine ansible_host=my.staging.host ansible_user=stager
Run Code Online (Sandbox Code Playgroud)

我正在使用不带SSH的SSH ControlMaster

我有一本有同步命令的剧本:

- name: Copy build to staging
  hosts: staging_machine
  tasks:
    - synchronize: src=... dest=...
      delegate_to: staging_machine
      remote_user: stager
Run Code Online (Sandbox Code Playgroud)

该命令提示输入错误用户的密码:

local-mac-user@my-staging-host's password:

因此,与其使用ansible_user清单中remote_user定义的任务或任务中定义的目标来连接目标(游戏中指定的主机),delegate-to不如使用我们连接到该框的用户作为目标主机。

我究竟做错了什么?我该如何解决?

编辑:它在2.0.2中工作,在2.1.x中不工作

小智 -1

尝试在您的 YAML 文件上设置成为:是和成为_用户:stager...这应该可以修复它...

https://docs.ansible.com/ansible/2.5/user_guide/become.html