如何在Chef配方中执行curl命令?

时间:2015-05-19 15:15:00

标签: curl chef

我有一个curl命令,它是soap请求,并且包含基本身份验证的标头。我需要在Chef配方中为自动化实现这个卷曲。所以每次我执行chef脚本时,我都会看到这个curl也被执行了。 请给我一个在chef脚本中添加curl命令的语法。

4 个答案:

答案 0 :(得分:6)

你不能使用http_request资源吗?

类似的东西:

http_request 'SOAP request' do
  url "http://www.example.com/example"
  message <xml request>
  action :post
end

答案 1 :(得分:4)

您可以在厨师食谱中使用bash命令

<properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
</properties>

从这里有这个例子:https://docs.chef.io/resource_bash.html。只要叫你curl命令。 请记住,这不是真正的厨师方式。只有在没有其他转义时才应使用bash资源。

答案 2 :(得分:0)

简单的command应该有效,与此相似。

  command "curl -m 5 -i -X POST -d \"payload={}\" http://www.some.place/here"

请参阅curl的手册页以了解如何添加http标头。

答案 3 :(得分:0)

您也可以使用bash资源。例如

bash 'make curl request' do
  cwd ::File.dirname(src_filepath)
  code <<-EOH
    curl -L https://github.com
    EOH
end

cwd是运行bash shell的目录。

相关问题