I am trying to write a custom facter module that incorporates a fact within a fact for the command via concatenation of the command string plus a facter fact variable:
Facter.add("customfact") do
setcode do
$string_to_parse = Facter::Util::Resolution.exec('somecommand' + $::fact)
end
end
Newbie to ruby and Puppet... 1. What would be the proper syntax to do something with this?
Here is an example of the output generated with the command:
TAG security-group sg-0a7a8a61 aws:cloudformation:stack-name awseb-e-5tzgj9fq5b-stack
I would need the security group and stack name.
You want to use Facter.value(:sourcefact)
inside your new fact to access the variable. As for getting the individual values, you probably want those as separate facts, but you could pipe 'somecommand' + Facter.value(:sourcefact) + ' | awk {"print $3"}'
will give you the security group (as an example).