Ask Your Question

What is the puppet way of invoking RESTful API for populating data ?

asked 2016-08-23 07:10:14 -0600

ChetAn P gravatar image

I want to populate some data . There is RESTful API provided by Application. What is the right way in puppet to invoke REST API and populate data in that application? Is there any inbuilt mechanism in puppet to invoke the RESTful API? Where should the code be executed, on puppet master or an agent (other than the store)?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2016-08-23 09:29:28 -0600

Mr_Sharma gravatar image

I am not sure what kind of data you want to populate. But, I can give you an idea how you can use the REST API (I guess, this is what exactly you looking for). The APIs provides curl commands which needs to be executed on puppet master. E.g.

curl -X GET -H 'Content-Type: application/json' --cert /etc/puppetlabs/puppet/ssl/certs/$(hostname -f).pem --key /etc/puppetlabs/puppet/ssl/private_keys/$(hostname -f).pem --cacert /etc/puppetlabs/puppet/ssl/ca/ca_crt.pem | python -m json.tool

This command you should execute on puppet master. This will interact with puppet master to fetch the details about the given node group in the command. The output would consist following:

"classes": {
    "alfresco": {
        "tomcat_war": "/opt/tomcat-4.1.5.war",
        "default_user": "tomcat",
        "dest_path": "/u01/app",
        "port": 8009,
"description": "This group is for testing",
"environment": "production",
"environment_trumps": false,
"id": "81a56981-bb96-44a8-93d7-f4415a903a38",
"name": "Testing",
"parent": "00000000-0000-4000-8000-000000000000",
"variables": {}

You can find uses of HTTP REST APIs here. Hope this helps.

edit flag offensive delete link more


I am trying to Call the Opnstack API through Puppet. Is there any way where we can call API in Puppet. My Scenario is I have puppet Master I have to login to Opnstack API through Puppet. So what should i do ? Please help me. My Confusion is Is there any way to Create Puppet Module OR Do i have to wr

ChetAn P gravatar imageChetAn P ( 2016-08-24 01:22:58 -0600 )edit

I am not clear on your requirements. what exactly you want to accomplish using OpenStack API from puppet? Do you want to integrate OpentStack provisioning with puppet master or you just want to execute API command from your puppet agent? You can edit your question accordingly. Thanks.

Mr_Sharma gravatar imageMr_Sharma ( 2016-08-24 01:56:53 -0600 )edit

Yes Rajeev, I have to just call the API of any other S/W through Puppet . Is it possible through Puppet ? If yes then How ?

ChetAn P gravatar imageChetAn P ( 2016-08-24 02:28:05 -0600 )edit

If you want to call curl commands from puppet agent, you can use exec resource in puppet. PS:

Mr_Sharma gravatar imageMr_Sharma ( 2016-08-24 02:54:12 -0600 )edit

answered 2017-08-16 13:34:58 -0600

pizzaops gravatar image

You would write a custom function to do this. You should not do this directly through the Puppet DSL.

Functions are written in Ruby, and then invoked from the Puppet DSL. For more, see the documentation on writing custom functions. They're relatively simple to make.

edit flag offensive delete link more

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


Asked: 2016-08-23 07:10:14 -0600

Seen: 1,604 times

Last updated: Aug 16 '17