curl output in variable using a function [closed]
I have a curl command as follows:
curl -H "X-Token: token val" -X GET http://nodename.domain.com:8200/v1/generic/appname/projectname/environment/username | jq -r .data.value
I would have to get the output from the above curl command and assign it to a variable in puppet, how do i do that?
I see that there is custom facts, generate command and custom functions. I am not sure which one to use and what is the difference between custom fact and custom function.
Also, the curl will be executed in the puppet agent node side, so i am not seeing generate as a best fit for this since in the docs it is mentioned it runs in the master. May be a ruby code for doing this ?
$username1 = get_username($token, hiera(‘key1’)) $password1 = get_password($token, hiera(‘key2’)) $username2 = get_username($token, hiera(‘key3’)) $password2 = get_password($token, hiera(‘key4’))
Please provide some examples, many thanks!