Guest User

Untitled

a guest
Jun 1st, 2012
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. #!/opt/puppet/bin/ruby
  2. require 'puppet'
  3. require 'puppet/face'
  4. require 'yaml'
  5. # assumes that this credential file has been laid down
  6. # should contain credentials with cloudformation:DescribeStackResource
  7. # access to the resource being classified
  8. credential_file='/var/lib/cfn-init/data/cfn-credentials'
  9.  
  10. # figure out which facts terminus to use
  11. # is this the best way to set runmode out side of an application?
  12. $puppet_application_mode = Puppet::Util::RunMode[:master]
  13. Puppet[:config]='/etc/puppetlabs/puppet/puppet.conf'
  14. Puppet.parse_config
  15. facts = Puppet::Face[:facts, :current].find(ARGV.first)
  16. if facts
  17. # right now this is hard coded for region us-east-1
  18. # the stackname and resource id facts are currently laid
  19. # down by the cloud formation script
  20. if facts.values['cfn_stack_name'] and facts.values['cfn_resource_id'] and File.exists?(credential_file)
  21. command = "/opt/aws/bin/cfn-get-metadata --region #{facts.values['cfn_region']} -s #{facts.values['cfn_stack_name']} -r #{facts.values['cfn_resource_id']} -f #{credential_file} --key Puppet"
  22. classification_meta_data = `#{command}`.downcase
  23. unless classification_meta_data == ''
  24. puts PSON.parse(classification_meta_data).to_yaml
  25. exit 0
  26. end
  27. end
  28. end
  29. puts({'classes' => []}.to_yaml)
Advertisement
Add Comment
Please, Sign In to add comment