Ask Your Question
0

class assignment to nodes using command line

asked 2016-07-04 09:45:37 -0500

rajeevsharma gravatar image

In my environment, we are controlling puppet runs a bit differently. we have tagged the available classes to nodes using node groups on PE console and running MCollective commands to trigger puppet run. In more different way, I have class version as tomcat1.3, tomcat1.4 etc.

E.g I have tagged tomcat1.3 class to webserver classification group and it's working fine. But it's a tedious job when I have tomcat1.4 class available and need to tag the new class to webserver and likewise 50 different node groups.

Is there any command available in PE to process class assignment using command line? I am sorry, if you find my question stupid. But this is my requirement and I am unable to find out a solution. I do not want to go with site.pp or hiera, command line is the only solution I am looking for.

edit retag flag offensive close merge delete

Comments

Hi rajeev, did you get any solution for this???

var kanduku gravatar imagevar kanduku ( 2016-09-07 15:27:06 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-09-09 04:25:41 -0500

rajeevsharma gravatar image

Hi Var, Yeah I found a solution recently and thanks for reminding to post here. If you are using PE and doing class assignment using classification node group then you can either add new classes or remove existing classes using CURL command. This is simple and handy to use and do not take much time to reflect on console. Please find the example below.

Adding a class with parameters:

curl -X POST -H 'Content-Type: application/json'   --cert /etc/puppetlabs/puppet/ssl/certs/puppetmaster.pem   --key /etc/puppetlabs/puppet/ssl/private_keys/puppetmaster.pem   --cacert /etc/puppetlabs/puppet/ssl/certs/ca.pem   -d '{ "classes": {"java": {"latest": "yes"}}}' https://puppetmaster:4433/classifier-api/v1/groups/93c2c931-fe6f-4570-8854-e10f7bc50235

Removing a class:

curl -X POST -H 'Content-Type: application/json'   --cert /etc/puppetlabs/puppet/ssl/certs/puppetmaster.pem   --key /etc/puppetlabs/puppet/ssl/private_keys/puppetmaster.pem   --cacert /etc/puppetlabs/puppet/ssl/certs/ca.pem   -d '{ "classes": {"tomcat": null}}' https://puppetmaster:4433/classifier-api/v1/groups/f3bb57e9-c814-4d64-8110-702e8def0037

To execute this command you need to use given keys and the group-id of node group (you can find this on console browser link when you open up the node group).

Note: If you are executing mco command as soon as you are adding a class using curl it won't work unless you run the agent is run once on your target node.

Hope this will help. Cheers!!!

edit flag offensive delete link more

Comments

Thanks rajeev . Can We also assign classes to nodes instead of assigning classes to node groups??

var kanduku gravatar imagevar kanduku ( 2016-09-09 16:41:49 -0500 )edit

Hi var, you have to create a nodegroup and pin one node to the group.
What you can do is to apply you class directly on the node using puppet apply.

FranzCC gravatar imageFranzCC ( 2016-09-16 02:33:08 -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

1 follower

Stats

Asked: 2016-07-04 09:45:37 -0500

Seen: 283 times

Last updated: Sep 09 '16