我想使用 Ansible 更新一些没有互联网访问权限的删除 Ubuntu 服务器,我已经在由 nginx http://localhost/media/apt托管的 Ansible 上下载了一个创建的存储库
为了远程服务器获取repo,我将sources.list 覆盖为:
deb http://127.0.0.1:88/media/apt trusty main
Run Code Online (Sandbox Code Playgroud)
我已经放入 ansible.cfg 文件:
[ssh_connection]
ssh_args = -R 88:127.0.0.1:80
Run Code Online (Sandbox Code Playgroud)
为了完整起见,这是我的 yml 文件:
- name: apt proxy configuration
copy:
src: sources.list
dest: /etc/apt/sources.list
- name: APT | ge repo key
apt_key:
data: "{{repository_key }}"
- name: Upgrade
apt:
update_cache: yes
allow_unauthenticated: yes
upgrade: dist
Run Code Online (Sandbox Code Playgroud)
该脚本完成了更新源文件、安装密钥和更新远程系统的工作,这太棒了。
然而,通过干扰 ssh_args,我对每项任务都感到不安,我现在收到两个警告:*
[警告]:sftp 传输机制在 [192.168.128.129] 上失败。使用 ANSIBLE_DEBUG=1 查看详细信息
[警告]:scp 传输机制在 [192.168.128.129] 上失败。使用 ANSIBLE_DEBUG=1 查看详细信息
我可以看到它正在将我的 ssh_args 选项添加到 sftp 和 scp 传输中
SSH: EXEC sftp -b - -R 88:127.0.0.1:80 -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 '[ 192.168.128.129]'
<192.168.128.129> SSH: EXEC sftp -b - -R 88:127.0.0.1:80 -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 '[192.168.128.129]' [警告]:sftp 传输机制在 [192.168.128.129] 上失败。使用 ANSIBLE_DEBUG=1 查看详细信息
<192.168.128.129> SSH:EXEC scp -R 88:127.0.0.1:80 -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 /tmp/tmp87UMuT '[192.168.128.129]:/root/.ansible/tmp/ansible-tmp-1509468784.12-45526153395602/setup.py' [警告]:scp 传输机制在 [192.168.128.19]2.8219 上失败 使用 ANSIBLE_DEBUG=1 查看详细信息
有没有一种方法可以在不破坏ansible scp和ftp连接的情况下使用反向代理连接到我的远程机器?
如果您通读有关 ssh 连接模块的文档,您将看到除了ssh_argsssh 相关的所有命令行都使用的 之外,还有许多*_extra_args选项:
ssh_extra_argsscp_extra_argssftp_extra_args这些参数将仅用于特定命令。换句话说,如果您使用,ssh_extra_args您应该一切就绪。
| 归档时间: |
|
| 查看次数: |
3576 次 |
| 最近记录: |