Class: Puppet::Application::Relay
- Inherits:
-
Puppet::Application
- Object
- Puppet::Application
- Puppet::Application::Relay
- Defined in:
- lib/puppet/application/relay.rb
Overview
This class extends puppet CLI framework to add a ‘puppet relay` subcommand for the relay agent.
Instance Method Summary collapse
Instance Method Details
#help ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/puppet/application/relay.rb', line 16 def help <<-HELP puppet-relay(8) -- #{summary} ======== SYNOPSIS -------- Runs a daemon process that polls Relay and starts Puppet agent runs when requested. USAGE ----- puppet relay [-h|--help] [-t|--test] [--daemonize|--no-daemonize] [-d|--debug] [-v|--verbose] [--config <FILE>] [-b|--backend <BACKEND>] [--backend-config <KEY1>=<VALUE1>[,<KEY2>=<VALUE2>[,...]]] OPTIONS ------- * --help: Print this help message. HELP end |
#main ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/puppet/application/relay.rb', line 41 def main with_daemon do work = PuppetX::Relay::Agent::Job::Work.new dispatch = PuppetX::Relay::Agent::Job::Dispatch.new(@ctx.backend, work, @ctx.settings[:state_dir]) if Puppet[:onetime] Puppet.notice(_('Running backend %{backend}') % { backend: @ctx.backend.class.name }) work.add(PuppetX::Relay::Agent::Job::Once.new(dispatch)) else Puppet.notice(_('Starting loop for backend %{backend} every 30 seconds') % { backend: @ctx.backend.class.name }) work.add(dispatch, 30) end sched = Puppet::Scheduler::Scheduler.new sched.run_loop(work) end end |
#setup ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/puppet/application/relay.rb', line 77 def setup if [:test] Puppet[:daemonize] = false Puppet[:onetime] = true [:verbose] = true end super cfg = PuppetX::Relay::Util::DefaultSettings.new cfg = PuppetX::Relay::Util::FileSettings.new(cfg, file: .delete(:config)) cfg = PuppetX::Relay::Util::OverlaySettings.new(cfg, ) cfg = PuppetX::Relay::Util::BackendOverlaySettings.new(cfg, @backend_options || {}) @ctx = PuppetX::Relay::Agent::Context.new(cfg) end |
#summary ⇒ Object
12 13 14 |
# File 'lib/puppet/application/relay.rb', line 12 def summary _('The agent for Relay by Puppet') end |