【发布时间】:2017-10-04 13:01:50
【问题描述】:
我在 10.251.130.45:8080 上运行 jenkins 服务器。 服务器位于代理后面。
- 我想使用 ansible 模块安装一些 jenkins 插件: jenkins_plugin
- 正在从标准位置获取插件:
"updates_url": "https://updates.jenkins-ci.org" 所以需要去 通过代理。 - 然而,基于 IP 地址的调用需要转到本地 jenkins 实例。
但是这失败了。我使用 ip 和 localhost 作为 jenkins 实例的 url 进行了测试。它似乎都转到了代理。
如何让 ansible 仅通过代理运行基于 DNS 的查询?
以前我一直在使用:
environment:
http_proxy: http://webproxy.ec.local:9090
https_proxy: http://webproxy.ec.local:9090
并且只需将代理设置为“”以重置使用本地主机地址的任务,但是,现在我需要同时使用本地主机和远程 url。 当然,我不想要代理的本地主机!
failed: [localhost] (item=authorize-project) => {
"details": "HTTP Error 502: cannotconnect",
"failed": true,
"invocation": {
"module_args": {
"attributes": null,
"backup": null,
"content": null,
"delimiter": null,
"directory_mode": null,
"follow": false,
"force": false,
"force_basic_auth": true,
"group": "jenkins",
"http_agent": "ansible-httpget",
"jenkins_home": "/var/lib/jenkins",
"mode": "0644",
"name": "authorize-project",
"owner": "jenkins",
"regexp": null,
"remote_src": null,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"src": null,
"state": "present",
"timeout": 500.0,
"unsafe_writes": null,
"updates_expiration": 86400,
"updates_url": "https://updates.jenkins-ci.org",
"url": "http://localhost:8080",
"url_password": "admin",
"url_username": "admin",
"use_proxy": true,
"validate_certs": true,
"version": null,
"with_dependencies": true
}
},
"item": "authorize-project",
"msg": "Cannot get CSRF"
一些使用 curl 的测试:
localhost 调用和 ansible 一样返回 502。
curl -X HEAD --proxy http://webproxy.ec.local:9090 -i localhost:8080 // 502
curl -X HEAD --proxy http://webproxy.ec.local:9090 -i 10.251.130.45:8080 // FAIL, timeout
curl -X HEAD -i http://10.251.130.45:8080 // 200 ok
【问题讨论】:
标签: curl proxy ansible jenkins-plugins