Class: Awstool::Settings
- Inherits:
-
Object
- Object
- Awstool::Settings
- Defined in:
- lib/awstool/settings.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
8 9 10 |
# File 'lib/awstool/settings.rb', line 8 def end |
Class Method Details
.get_flags ⇒ Object
22 23 24 25 26 27 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 |
# File 'lib/awstool/settings.rb', line 22 def self.get_flags OptionParser.new do |opts| opts. = 'Usage: awstool [options] hostname' opts.on('-h', '--help', 'Prints this help') do puts opts exit end opts.on('-f', '--facts FACT1,FACT2', Array, 'Seed new instance with puppet facts') do |facts| facts.each do |fact| split_fact = fact.split('=') ['facts'][split_fact.first] = split_fact[1] end end opts.on('-t', '--tags TAG1,TAG2', Array, 'Set EC2 instance tags') do || .each do |tag| split_tag = tag.split('=') ['tags'][split_tag.first] = split_tag[1] end end opts.on('--debug', 'Prints some extra output helpful for debugging') do ['debug'] = true end opts.on('-s', '--subnet-id-index INDEX', 'Select a subnet-id from you subnet-ids array.') do |index| ['subnet-id-index'] = index.to_i end opts.on( '-o', '--options-file FILE1,FILE2', Array, 'List option files that will merge and override settings in .awstool.yaml. Last entry takes precedence.' ) do |of| of.each do |f| @option_files << Psych.load_file(File.(f)) end end end.parse! if ARGV.empty? puts "hostname string is required." exit 1 else ['hostnames'] = ARGV end end |
.get_options ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/awstool/settings.rb', line 10 def self. set_default get_rc get_flags @option_files.each do |f| .merge!(f) end end |
.get_rc ⇒ Object
73 74 75 76 77 78 79 |
# File 'lib/awstool/settings.rb', line 73 def self.get_rc awsconf = "#{ENV['HOME']}/.awstool.yaml" if File.exist?(awsconf) .merge!(Psych.load_file(awsconf)) end ['subnet-id-index'] = rand(['subnet-ids'].length - 1 ) end |
.set_default ⇒ Object
81 82 83 84 85 86 87 88 89 |
# File 'lib/awstool/settings.rb', line 81 def self.set_default ['userdata'] = File.(File.dirname(__FILE__)) + '/../../userdata/default.erb' ['facts'] = {} ['tags']= {} ['hostnames'] = [] ['rootvol_size'] = 8 ['block_devices'] = false ['timezone'] = 'UTC' end |