0

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?

  1. Is there any way to parse the output into an array of facts or what is the correct way to search the $string_to_parse for the content I need.

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.

4

1 に答える 1

0

Facter.value(:sourcefact)変数にアクセスするには、新しいファクト内で使用します。個々の値の取得に関しては、おそらくそれらを個別のファクトとして取得する必要がありますが、パイプ'somecommand' + Facter.value(:sourcefact) + ' | awk {"print $3"}'を使用してセキュリティ グループを取得できます (例として)。

于 2014-04-09T05:24:16.980 に答える