ansible - Ansible Synchronize 模块在测试时卡住
问题描述
目标:我正在尝试/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
我在本地主机上运行这个剧本。我除此之外是foo
在那时连接,到组服务器的tower.example.com
ssh和rsync 推送与过滤器匹配的文件夹的内容。foo
web
staging
- 我可以在 tower.example.com 上运行其他剧本
- 我可以在 tower.example.com 上与我的用户连接,然后连接
sudo -i && su foo
到 foo。 - 作为 foo,我可以作为 foo 连接到其他主机,用于组 web 和 staging 下的服务器。
我错过了什么?
解决方案
看起来tower.example.com
可能没有对其他主机的 ssh 访问权限。这会导致 Ansible 在 ssh 等待密码时卡住。您可以通过以下方式解决此问题
- 在其他主机上生成新的 ssh 密钥
tower.example.com
并对其进行授权,和/或 - 设置ssh-agent 转发。
或者,您可以将证书提取到临时文件夹localhost
并将它们复制到其他主机。这避免了使用delegate_to
,但不如直接在远程主机之间同步文件高效。
推荐阅读
- android - android 3.1.3 中的依赖问题
- hadoop - 启动hadoop服务时ssh密钥不起作用
- arrays - java中如何在数组中插入元素
- python - Keras 可以预取 tensorflow Dataset 之类的数据吗?
- python - 在使用另一个列表作为参考python时在列表中查找字符串
- data-modeling - 二维或事实与维度之间的一对多关系
- twitter-bootstrap - 使用 vuejs 更改禁用下拉文本的颜色
- android - Android:应用重新打开后恢复 RecyclerView 项目位置
- python - 从 python 脚本导入变量到 jupyter ipython notebook
- centos7 - CentOS 7 sudo >> -E:找不到命令