Created
September 27, 2013 22:32
-
-
Save jpadams/6736154 to your computer and use it in GitHub Desktop.
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 characters
| #!/opt/puppet/bin/ruby | |
| # | |
| # = Synopsis | |
| # | |
| # Collect and display facts about the system. | |
| # | |
| # = Usage | |
| # | |
| # facter [-d|--debug] [-h|--help] [-p|--puppet] [-v|--version] [-y|--yaml] [-j|--json] [--external-dir DIR] [--no-external-dir] [fact] [fact] [...] | |
| # | |
| # = Description | |
| # | |
| # Collect and display facts about the current system. The library behind | |
| # Facter is easy to expand, making Facter an easy way to collect information | |
| # about a system from within the shell or within Ruby. | |
| # | |
| # If no facts are specifically asked for, then all facts will be returned. | |
| # | |
| # = Options | |
| # | |
| # yaml:: | |
| # Emit facts in YAML format. | |
| # | |
| # json:: | |
| # Emit facts in JSON format. | |
| # | |
| # puppet:: | |
| # Load the Puppet libraries, thus allowing Facter to load Puppet-specific facts. | |
| # | |
| # version:: | |
| # Print the version and exit. | |
| # | |
| # help:: | |
| # Print this help message. | |
| # | |
| # debug:: | |
| # Enable debugging. | |
| # | |
| # trace:: | |
| # Enable backtraces. | |
| # | |
| # timing:: | |
| # Enable timing. | |
| # | |
| # facts.d:: | |
| # The directory to use for external facts. | |
| # | |
| # = Example | |
| # | |
| # facter kernel | |
| # | |
| # = Author | |
| # | |
| # Luke Kanies | |
| # | |
| # = Copyright | |
| # | |
| # Copyright (c) 2011 Puppet Labs, Inc | |
| # Licensed under the Apache 2.0 license | |
| # Bundler and rubygems maintain a set of directories from which to | |
| # load gems. If Bundler is loaded, let it determine what can be | |
| # loaded. If it's not loaded, then use rubygems. But do this before | |
| # loading any facter code, so that our gem loading system is sane. | |
| if not defined? ::Bundler | |
| begin | |
| require 'rubygems' | |
| rescue LoadError | |
| end | |
| end | |
| require 'facter/application' | |
| ARGV << '--puppet' unless ARGV.include?('--puppet') || ARGV.include?('-p') | |
| facts = Facter::Application.run(ARGV) | |
| yfacts = Hash[facts.to_a].to_yaml + "\n" | |
| File.open("/etc/puppetlabs/mcollective/facts.yaml.new", 'w') { |file| file.write(yfacts) } | |
| FileUtils.cp("/etc/puppetlabs/mcollective/facts.yaml.new", "/etc/puppetlabs/mcollective/facts.yaml", options = {}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment