【发布时间】:2019-11-11 13:54:36
【问题描述】:
我想在 ansible playbook 上做一些 curl,但总是失败。但是当我卷曲到远程主机本身时,它就成功了。
我试过了:
- 使用 ansible uri 模块
- shell 模块(原始 shell bash)
- 当前的一个是,我使用 shell 模块创建执行 curl 的可执行 .sh,然后执行它。
它们都不起作用。
这是我当前的代码:
- name: Write script to insert dummy data
become_user: root
shell: |
echo "curl {{'http://localhost:8080/insetdummydata'}}" > "/home/ubuntu/insert.txt"
- name: Make script executable
become_user: root
shell: chmod +x /home/ubuntu/wildduck/insert.sh
- name: Execute script to insert dummy data
become_user: root
shell: /home/ubuntu/wildduck/insert.sh
输出应在控制台上打印响应,但由于状态连接被拒绝而失败。 Here is the error message
我在上面提到过,如果我在远程机器本身上进行 curl,则该命令有效。输出应打印请求的响应。 This is the output when i do the curl from remote host.
我在配置剧本时是否遗漏了什么?
【问题讨论】:
-
请不要将文字作为图片发布。只需内联添加它。另外,这实际上是产生错误的剧本吗?使用 URL 作为变量的语法很奇怪。您能否将 shell 命令更改为仅
curl http://localhost:8080/insetdummydata并使用-vvv发布 playbook run 的输出以进行调试输出?