在测试

时间:2018-04-24 13:00:11

标签: ansible

目标:我试图复制/home/foo/certificates/*/{fullchain.cer,*.key} 从一个服务器(tower.example.com)到其他节点。

使用verbose选项尝试任务时,它会被卡住。输出日志可以在那里找到(Ansible 2.5):https://gist.github.com/tristanbes/1be96509d4853d647a49d30259672779

- hosts: staging:web:tower:!tower.example.com
  gather_facts: yes
  become: yes
  become_user: foo
  tasks:
    - name: synchronize the certificates folder
      synchronize:
        src: "/home/foo/certificates/"
        dest: "{{ certificates_path }}/"
        rsync_opts:
          - "--include=fullchain.cer"
          - "--include=*.key"
      delegate_to: tower.example.com

我在localhost上运行这个剧本。 我除此之外的是以foo上的tower.example.com连接,然后以foo ssh连接到群组webstaging的服务器以推送内容与过滤器匹配的文件夹。

  • 我可以在tower.example.com
  • 上运行其他剧本
  • 我可以在tower.example.com上与我的用户连接,然后sudo -i && su foo与foo连接。
  • 作为foo,我可以连接到其他主机作为foo,用于组web和​​登台下的服务器。

我错过了什么?

1 个答案:

答案 0 :(得分:0)

看来tower.example.com可能没有对其他主机的ssh访问权限。这将导致Ansible在ssh等待密码时卡住。您可以通过以下方式解决此问题:

  • tower.example.com上生成一个新的ssh密钥,并在其他主机上对其进行授权,和/或
  • 设置ssh-agent forwarding

或者,您可以将证书提取到localhost上的temp文件夹中,然后将其复制到其他主机上。这样可以避免使用delegate_to,但效率不如直接在远程主机之间同步文件。

相关问题