Class: Buratino::Configure
- Inherits:
-
Object
- Object
- Buratino::Configure
- Defined in:
- lib/buratino/configure.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(configfile = '/usr/local/etc/buratino.yaml') ⇒ Configure
constructor
A new instance of Configure.
- #parse ⇒ Object
Constructor Details
#initialize(configfile = '/usr/local/etc/buratino.yaml') ⇒ Configure
Returns a new instance of Configure.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/buratino/configure.rb', line 11 def initialize( configfile='/usr/local/etc/buratino.yaml' ) puts "DEBUG BURATINO::CONFIGURE::NEW" @config = YAML.load_file( configfile ) @options = Hash.new @options['puppet'] = @config['puppet_url'] @options['destination'] = @config['destination'] @options['reports_dir'] = @config['reports_dir'] @options['reports'] = @config['reports_url'] @options['interval'] = @config['interval'] @options['fqdn'] = Facter.fqdn @options['angel'] = false # Different Modes: clone, update @options['mode'] = @config['mode'] end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
9 10 11 |
# File 'lib/buratino/configure.rb', line 9 def @options end |
Instance Method Details
#parse ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/buratino/configure.rb', line 28 def parse puts "DEBUG BURATINO::CONFIGURE::PARSE" OptionParser.new do |opt| opt.separator "" opt.separator "Usage: buratino [--angel] --fqdn <hostname> -p <puppet repostory> -r <reports repository> -m <mode> -i <interval>" opt.separator "" opt.separator "Options:" opt.separator "-------------" opt.on('', '--fqdn FQDN', 'FQDN hostname') { |val| @options['fqdn'] = val } opt.on('-p', '--puppet PUPPET-REPOS', 'Puppet repository') { |val| @options['puppet'] = val } opt.on('-a', '--angel', 'Angel mode - no-daemonize') { @options['angel'] = true } opt.on('-r', '--reports REPORTS-REPOS', 'Reports repository') { |val| @options['reports'] = val } opt.on('-m', '--mode MODE', 'Mode: clone|update') { |val| @options['mode'] = val } opt.on('-i', '--interval', 'Interval in seconds') { |val| @options['interval'] = val } opt.separator "" opt.separator "All options can be set in config file" opt.on_tail('-h', '--help') { puts opt; exit } opt.parse! end self. end |