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.
3
votes
What's your ultimate goal? This contradicts with the idempodency thinking. Do you want that for some kind of reporting/monitoring of your chef runs? Instead of executing command, you can also use Ruby's http client.
- StephenKing
Correct Stephen, considering calling the external REST API using ruby and wrapping this as Light weight resource. If on the other hand your just calling the external service to set some node data and really good approach is to call the REST service as a ohai plugin. Lots of options more detail would enable better advice.
- Mark O'Connor
4 Answers
6
votes
5
votes
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.
0
votes