Ask Your Question
0

Can I add the "--tags" option to a puppet api run call?

asked 2014-12-23 05:51:25 -0500

bleecky gravatar image

I'm setting up a job in jenkins which uses the puppet api to trigger a puppet run on a series of remote servers (I will update this in the future with MCollective but we're not ready for that yet!)

What would be nice in the short term is to use the --tags in the api call to only run a particular role or profile, does any body know if this is possible and how I would go about doing it?

My existing curl command is :

curl --cert /var/lib/puppet/ssl/certs/myhost.pem --key /var/lib/puppet/ssl/private_keys/myhost.pem --cacert /var/lib/puppet/ssl/certs/ca.pem  -k -X PUT -H "Content-Type: text/pson" -d "{}" https://myremotehost:8139/Production/run/myremotehost

Thank you.

edit retag flag offensive close merge delete

Comments

What edition and version of Puppet are you using? Also, how do you have your environments configured - dynamic or the new directory environments?

GregLarkin gravatar imageGregLarkin ( 2014-12-23 12:20:01 -0500 )edit

Thanks for the response, been away for Christmas hence the delay, currently we are using the Open Source version at 3.4.2 but looking to go to 3.6. or 3.7 and we are currently using dynamic environments.

bleecky gravatar imagebleecky ( 2014-12-30 13:53:27 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2014-12-30 19:38:59 -0500

cbarbour gravatar image

A quick review of the manual shows that tags is supported by the puppet kick command, which uses the puppetrun REST API. I did a bit of digging through the code, and while I wasn't able to entirely decipher the REST indirector, it looks like you can pass tags as part of the PSON data submitted with the run request.

Try this:

curl --cert /var/lib/puppet/ssl/certs/myhost.pem --key /var/lib/puppet/ssl/private_keys/myhost.pem --cacert /var/lib/puppet/ssl/certs/ca.pem -k -X PUT -H "Content-Type: text/pson" -d '{ "tags" : "tagone,tagtwo" }' https://myremotehost:8139/Production/run/myremotehost

Note that I've added some additional data to the request. -d '{ "tags" : "tagone,tagtwo" }'

The other kick arguments also seem to be supported; tags ignoreschedules & pluginsync.

edit flag offensive delete link more

Comments

This does exactly what I was hoping for, thank you very much for your help.

bleecky gravatar imagebleecky ( 2015-01-01 12:11:41 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2014-12-23 05:51:25 -0500

Seen: 282 times

Last updated: Dec 30 '14