Class: Buratino::Configure

Inherits:
Object
  • Object
show all
Defined in:
lib/buratino/configure.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#optionsObject (readonly)

Returns the value of attribute options.



9
10
11
# File 'lib/buratino/configure.rb', line 9

def options
  @options
end

Instance Method Details

#parseObject



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.options
end