Hey y'all. Running into another issue. Instead of writing huge curls over and over in puppet, I can variablize it depending on the environment. However, it is not like my variable in the JSON. I have tried numerous corrections but the color is not going through. When I check the watches on my instance, it just shows "color":""
## Set-up variables
if ($tier_level == 'prod'){
$color = 'red'
}else{
$color = 'yellow'
}
exec { 'api curl':
command => "sudo curl -XPUT 'localhost:9200/_watcher/watch/api-error' -d '{
\"trigger\" : {
\"schedule\" : { \"interval\" : \"10s\" }
},
\"input\" : {
\"search\" : {
\"request\" : {
\"indices\" : [ \"filebeat\" ],
\"body\" : {
\"query\" : {
\"filtered\" : {
\"query\" : {
\"match_phrase\" : { \"source\": \"/var/www/html/logs/error_log\" }
},
\"filter\" : {
\"bool\": {
\"must\": [
{
\"range\": {
\"@timestamp\" : {
\"from\" : \"now-5m\",
\"to\" : \"now\"
}
}
}
]
}
}
}
}
}
}
}
},
\"actions\" : {
\"notify-hipchat\" : {
\"throttle_period\" : \"1m\",
\"hipchat\" : {
\"account\" : \"notify-dev-monitoring\",
\"message\" : {
\"body\": \"{{#ctx.payload.hits.hits}}New error seen in api apache error_log! \n\nHost: {{_source.beat.hostname}}\nMessage: {{_source.message}} \n------------------------------------------------------------------------------\n{{/ctx.payload.hits.hits}}\",
\"format\" : \"text\",
\"color\" : \"$color\",
\"notify\" : true
}
}
}
}
}'
",
before => Exec['web curl']
}
Have tried ${color}, $color, {$color}, with single quotes/double quotes/alone.. Nothing seems to work. Please send help!!