-
-
Save tmclaugh/6a0ff5013ce10e5a0cd5 to your computer and use it in GitHub Desktop.
Revisions
-
Tom McLaughlin revised this gist
Apr 7, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,7 +8,7 @@ instance = ec2.describe_instances(instance_ids:[instance_id]) tags = instance.reservations[0].instances[0].tags tags.each do |tag| fact = "ec2_tag_#{tag["key"].gsub(/\-|\/|:/, '_')}" Facter.add(fact) { setcode { tag["value"] } } end Facter.add("ec2_region") { setcode { region } } -
dragosboca revised this gist
Mar 12, 2015 . 1 changed file with 13 additions and 11 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,14 +1,16 @@ require 'facter' require 'aws-sdk' if Facter.value("ec2_instance_id") != nil instance_id = Facter.value("ec2_instance_id") region = Facter.value("ec2_placement_availability_zone")[0..-2] ec2 = Aws::EC2::Client.new(region:region) instance = ec2.describe_instances(instance_ids:[instance_id]) tags = instance.reservations[0].instances[0].tags tags.each do |tag| fact = "ec2_tag_#{tag["key"]}" Facter.add(fact) { setcode { tag["value"] } } end Facter.add("ec2_region") { setcode { region } } end -
rafaelfelix revised this gist
Jul 8, 2013 . 1 changed file with 3 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,9 +1,10 @@ require 'facter' require 'json' if Facter.value("ec2_instance_id") != nil instance_id = Facter.value("ec2_instance_id") region = Facter.value("ec2_placement_availability_zone")[0..-2] tags = Facter::Util::Resolution.exec("aws ec2 describe-tags --filters \"name=resource-id,values=#{instance_id}\" --region #{region} | jq '[.Tags[] | {key: .Key, value: .Value}]'") parsed_tags = JSON.parse(tags) parsed_tags.each do |tag| -
rafaelfelix revised this gist
Jul 5, 2013 . 1 changed file with 9 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,11 +1,13 @@ require 'facter' require 'json' if Facter.value("ec2_instance_id") =! nil instance_id = Facter.value("ec2_instance_id") tags = Facter::Util::Resolution.exec("aws ec2 describe-tags --filters \"name=resource-id,values=#{instance_id}\" --region sa-east-1 | jq '[.Tags[] | {key: .Key, value: .Value}]'") parsed_tags = JSON.parse(tags) parsed_tags.each do |tag| fact = "ec2_tag_#{tag["key"]}" Facter.add(fact) { setcode { tag["value"] } } end end -
rafaelfelix revised this gist
Jul 5, 2013 . 1 changed file with 8 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,9 +1,11 @@ require 'facter' require 'json' instance_id = Facter.value("ec2_instance_id") tags = Facter::Util::Resolution.exec("aws ec2 describe-tags --filters \"name=resource-id,values=#{instance_id}\" --region sa-east-1 | jq '[.Tags[] | {key: .Key, value: .Value}]'") parsed_tags = JSON.parse(tags) parsed_tags.each do |tag| fact = "ec2_tag_#{tag["key"]}" Facter.add(fact) { setcode { tag["value"] } } end -
drohr created this gist
Feb 27, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,9 @@ require 'facter' instance_id = Facter::Util::Resolution.exec("ec2-metadata -i | awk '{print $2}'") tags = Facter::Util::Resolution.exec("ec2-describe-tags --region eu-west-1 --filter \"resource-id=#{instance_id}\" | cut -f 4-") tags.scan(/(\w+)\s+(\w+)/) do |key, value| fact = "ec2_tag_#{key}" Facter.add(fact) { setcode { value } } end