Class: Puppet::Application::UploadFacts
- Inherits:
-
Puppet::Application
- Object
- Puppet::Application
- Puppet::Application::UploadFacts
- Defined in:
- ext/upload_facts.rb
Constant Summary
Constants inherited from Puppet::Application
DOCPATTERN, SHOULD_PARSE_CONFIG_DEPRECATION_MSG
Constants included from Util
Util::AbsolutePathPosix, Util::AbsolutePathWindows, Util::DEFAULT_POSIX_MODE, Util::DEFAULT_WINDOWS_MODE
Constants included from Util::POSIX
Util::POSIX::LOCALE_ENV_VARS, Util::POSIX::USER_ENV_VARS
Constants included from Util::SymbolicFileMode
Util::SymbolicFileMode::SetGIDBit, Util::SymbolicFileMode::SetUIDBit, Util::SymbolicFileMode::StickyBit, Util::SymbolicFileMode::SymbolicMode, Util::SymbolicFileMode::SymbolicSpecialToBit
Instance Attribute Summary
Attributes inherited from Puppet::Application
Instance Method Summary collapse
Methods inherited from Puppet::Application
[], #app_defaults, available_application_names, banner, clear!, clear?, clear_everything_for_tests, #configure_indirector_routes, controlled_run, exit, find, #handle_logdest_arg, #handlearg, #initialize, #initialize_app_defaults, interrupted?, #log_runtime_environment, #name, option, option_parser_commands, #parse_options, #preinit, restart!, restart_requested?, #run, #run_command, run_mode, #set_log_level, #setup_logs, should_not_parse_config, should_parse_config, should_parse_config?, stop!, stop_requested?, try_load_class
Methods included from Util
absolute_path?, activerecord_version, benchmark, binread, chuser, classproxy, deterministic_rand, execfail, execpipe, execute, exit_on_fail, logmethods, memory, path_to_uri, pretty_backtrace, proxy, replace_file, safe_posix_fork, symbolizehash, thinmark, uri_to_path, which, withenv, withumask
Methods included from Util::POSIX
#get_posix_field, #gid, #idfield, #methodbyid, #methodbyname, #search_posix_field, #uid
Methods included from Util::SymbolicFileMode
#normalize_symbolic_mode, #symbolic_mode_to_int, #valid_symbolic_mode?
Constructor Details
This class inherits a constructor from Puppet::Application
Instance Method Details
#help ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'ext/upload_facts.rb', line 28 def help print "== Synopsis\n\nUpload cached facts to the inventory service.\n\n= Usage\n\nupload_facts [-d|--debug] [-v|--verbose] [-m|--minutes <minutes>]\n [-l|--logdest syslog|<file>|console]\n\n= Description\n\nThis command will read YAML facts from the puppet master's YAML directory, and\nsave them to the configured facts_terminus. It is intended to be used with the\nfacts_terminus set to inventory_service, in order to ensure facts which have\nbeen cached locally due to a temporary failure are still uploaded to the\ninventory service.\n\n= Usage Notes\n\nupload_facts is intended to be run from cron, with the facts_terminus set to\ninventory_service. The +--minutes+ argument should be set to the length of time\nbetween upload_facts runs. This will ensure that only new YAML files are\nuploaded.\n\n= Options\n\nNote that any setting that's valid in the configuration file\nis also a valid long argument. For example, 'server' is a valid configuration\nparameter, so you can specify '--server <servername>' as an argument.\n\nSee the configuration file documentation at\nhttp://docs.puppetlabs.com/references/stable/configuration.html for\nthe full list of acceptable parameters. A commented list of all\nconfiguration options can also be generated by running puppet agent with\n'--genconfig'.\n\nminutes::\nLimit the upload only to YAML files which have been added within the last n\nminutes.\n" exit end |
#main ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'ext/upload_facts.rb', line 89 def main dir = Pathname.new(Puppet[:yamldir]) + 'facts' cutoff = [:time_limit] ? Time.now - [:time_limit] : Time.at(0) files = dir.children.select do |file| file.extname == '.yaml' && file.mtime > cutoff end failed = false terminus = Puppet::Node::Facts.indirection.terminus files.each do |file| facts = YAML.load_file(file) request = Puppet::Indirector::Request.new(:facts, :save, facts) # The terminus warns for us if we fail. if terminus.save(request) Puppet.info "Uploaded facts for #{facts.name} to inventory service" else failed = true end end exit !failed end |
#setup ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'ext/upload_facts.rb', line 74 def setup # Handle the logging settings. if [:debug] or [:verbose] if [:debug] Puppet::Util::Log.level = :debug else Puppet::Util::Log.level = :info end Puppet::Util::Log.newdestination(:console) unless [:setdest] end exit(Puppet.settings.print_configs ? 0 : 1) if Puppet.settings.print_configs? end |