firefox - Ansible 与 SSH X11 转发
问题描述
我需要在一些需要 DISPLAY 编号的服务器上为 Firefox 创建默认配置文件。我不知道如何用 Ansible 做到这一点。我一直试图让 X11 转发工作,但没有成功。我不能更改 SSH 配置,所以我不能从那里启用 X11。我怎样才能用 Ansible 做到这一点?
我尝试了以下方法:
- name: Create default profile shell: firefox -createprofile "default /opt/profiles/default"
并将
ssh_args
in设置ansible.cfg
为:ssh_args= -X
这失败了:
ssh连接主机失败:ssh: connect to host as1 port 22: No route to host
- name: Create default profile shell: | export DISPLAY=:0.0 firefox -createprofile "default /opt/profiles/default"
不添加
ssh_args = -X option
这失败了:
未指定协议,错误:无法打开显示::0.0
我可以ssh -X user@as1
成功运行:firefox -createprofile "default /opt/profiles/default"
必须有办法做到这一点,但我不知道还有什么可以尝试的。
解决方案
一般来说,不仅仅是针对特定的 firefox 情况,在 ssh 参数中添加“-o ForwardX11=yes”选项应该可以解决问题。你可以这样做:
- 从命令行设置 ANSIBLE_SSH_ARGS,如下所示:
ANSIBLE_SSH_ARGS='-C -o ForwardX11=yes -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no' ansible-playbook -i hosts.ini test.yml
- 更新 ansible.cfg 文件:
[ssh_connection]
ssh_args = -C -o ForwardX11=yes -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no
- 我的首选方式,在 hosts.ini 文件中设置 ansible_ssh_extra_args,例如:
[all]
hostname ansible_host=10.0.0.1 ansible_user=user ansible_ssh_extra_args='-o ForwardX11=yes'
推荐阅读
- google-apps-script - YouTube.Thumbnails.set() 出错(未找到 videoID)
- python - 在 Jupyter 笔记本中更改音量
- highcharts - Highcharts:条形柱在x轴上以统一的方式对齐
- android-studio - 使用数据绑定时如何格式化字符串?
- python - 使用不带函数的 discord.py 发送消息
- typescript - 打字稿:未找到 global.d.ts
- reactjs - 从数组更新状态
- asp.net-core - 尝试将视图字段设置为字符串,但未提交字符串
- xamarin - 每次 Xamarin.Android 拒绝权限请求对话框时都会调用 OnAppearing
- java - Android Studio UI:ImageView 调整大小后的 TextView 位置偏移