Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to execute curl command in Chef recipe?

I have a curl command which is soap request and with headers like basic auth. I need to implement this curl in Chef recipe for automation.So that every time i execute the chef script ,i see this curl being executed too. Please advice me with a syntax for adding curl command in the chef script.

like image 852
Grin like a Cheshire cat Avatar asked Sep 20 '25 10:09

Grin like a Cheshire cat


2 Answers

Couldn't you do this using the http_request resource?

Something like:

http_request 'SOAP request' do
  url "http://www.example.com/example"
  message <xml request>
  action :post
end
like image 93
Chaz Ruhl Avatar answered Sep 23 '25 17:09

Chaz Ruhl


You can use bash commands in a chef recipe

bash 'install_something' do
  user 'root'
  cwd '/tmp'
  code <<-EOH
  wget http://www.example.com/tarball.tar.gz
  tar -zxf tarball.tar.gz
  cd tarball
  ./configure
  make
  make install
  EOH
end

Have this example from here: https://docs.chef.io/resource_bash.html. Just call you curl command. Keep in mind that this is not the real Chef way. The bash resource should only be used if there is no other escape.

like image 23
NaN Avatar answered Sep 23 '25 18:09

NaN