Class: Rudy::Config
- Inherits:
-
Caesars::Config
- Object
- Caesars::Config
- Rudy::Config
- Defined in:
- lib/rudy/config.rb,
lib/rudy/config/objects.rb
Defined Under Namespace
Classes: Accounts, Commands, Controls, Defaults, Error, Machines, Networks, Routines, Services
Class Method Summary collapse
Instance Method Summary collapse
-
#accounts? ⇒ Boolean
dsl Rudy::Config::Networks::DSL # Network design dsl Rudy::Config::Controls::DSL # Network access dsl Rudy::Config::Services::DSL # Stuff running on ports.
-
#commands? ⇒ Boolean
n.
-
#controls? ⇒ Boolean
e.
-
#defaults? ⇒ Boolean
u.
- #look_and_load(adhoc_path = nil) ⇒ Object
-
#machines? ⇒ Boolean
t.
-
#networks? ⇒ Boolean
g.
-
#postprocess ⇒ Object
This method is called by Caesars::Config.refresh for every DSL file that is loaded and parsed.
-
#routines? ⇒ Boolean
o.
-
#services? ⇒ Boolean
!.
Class Method Details
.init_config_dir ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/rudy/config.rb', line 78 def self.init_config_dir unless File.exists?(Rudy::CONFIG_DIR) puts "Creating #{Rudy::CONFIG_DIR}" Dir.mkdir(Rudy::CONFIG_DIR, 0700) end unless File.exists?(Rudy::CONFIG_FILE) puts "Creating #{Rudy::CONFIG_FILE}" rudy_config = Rudy::Utils.without_indent %Q{ accounts do # Account Access Indentifiers aws do # amazon web services name "Rudy Default" accountnum "" accesskey "" secretkey "" privatekey "~/path/2/pk-xxxx.pem" cert "~/path/2/cert-xxxx.pem" end end defaults do # Global Defaults region :"us-east-1" zone :"us-east-1b" environment :stage role :app user Rudy.sysinfo.user.to_sym color false # Terminal colors? true/false yes false # Auto-confirm? true/false end } Rudy::Utils.write_to_file(Rudy::CONFIG_FILE, rudy_config, 'w', 0600) end end |
Instance Method Details
#accounts? ⇒ Boolean
dsl Rudy::Config::Networks::DSL # Network design dsl Rudy::Config::Controls::DSL # Network access dsl Rudy::Config::Services::DSL # Stuff running on ports
17 |
# File 'lib/rudy/config.rb', line 17 def accounts?; self.respond_to?(:accounts) && !self[:accounts].nil?; end |
#commands? ⇒ Boolean
n
23 |
# File 'lib/rudy/config.rb', line 23 def commands?; self.respond_to?(:commands) && !self[:commands].nil?; end |
#controls? ⇒ Boolean
e
22 |
# File 'lib/rudy/config.rb', line 22 def controls?; self.respond_to?(:controls) && !self[:controls].nil?; end |
#defaults? ⇒ Boolean
u
18 |
# File 'lib/rudy/config.rb', line 18 def defaults?; self.respond_to?(:defaults) && !self[:defaults].nil?; end |
#look_and_load(adhoc_path = nil) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/rudy/config.rb', line 49 def look_and_load(adhoc_path=nil) cwd = Dir.pwd cwd_path = File.join(cwd, '.rudy', 'config') # Attempt to load the core configuration file first. # The "core" config file can have any or all configuration # but it should generally only contain the access identifiers # and defaults. That's why we only load one of them. core_config_paths = [adhoc_path, cwd_path, Rudy::CONFIG_FILE] core_config_paths.each do |path| next unless path && File.exists?(path) @paths << path break end typelist = self.keys.collect { |g| "#{g}.rb" }.join(',') # Rudy then looks for the rest of the config in these locations @paths += Dir.glob(File.join(cwd, 'Rudyfile')) || [] @paths += Dir.glob(File.join(cwd, 'config', 'rudy', '*.rb')) || [] @paths += Dir.glob(File.join(cwd, '.rudy', '*.rb')) || [] @paths += Dir.glob(File.join(cwd, "{#{typelist}}")) || [] @paths += Dir.glob(File.join('/etc', 'rudy', '*.rb')) || [] @paths &&= @paths.uniq refresh end |
#machines? ⇒ Boolean
t
19 |
# File 'lib/rudy/config.rb', line 19 def machines?; self.respond_to?(:machines) && !self[:machines].nil?; end |
#networks? ⇒ Boolean
g
21 |
# File 'lib/rudy/config.rb', line 21 def networks?; self.respond_to?(:networks) && !self[:networks].nil?; end |
#postprocess ⇒ Object
This method is called by Caesars::Config.refresh for every DSL file that is loaded and parsed. If we want to run processing for a particular config (machines, @routines, etc…) we can do it here. Just wait until the instance variable is not nil.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/rudy/config.rb', line 30 def postprocess #raise "There is no AWS info configured" if self.accounts.nil? # These don't work anymore. Caesars bug? #if accounts? && !self.accounts.aws.nil? # self.accounts.aws.cert &&= File.expand_path(self.accounts.aws.cert) # self.accounts.aws.privatekey &&= File.expand_path(self.accounts.aws.privatekey) #end # The commands config modifies the way the routines configs # should be parsed. This happens in the postprocess method # we call here. We can't guarantee this will run before the # routines config is loaded so this postprocess method will # raise a Caesars::Config::ForceRefresh exception if that's # the case. Rudy::Config::Commands knows to only raise the # exception one time (using a boolean flag in a class var). @commands.postprocess if @commands end |
#routines? ⇒ Boolean
o
20 |
# File 'lib/rudy/config.rb', line 20 def routines?; self.respond_to?(:routines) && !self[:routines].nil?; end |
#services? ⇒ Boolean
!
24 |
# File 'lib/rudy/config.rb', line 24 def services?; self.respond_to?(:services) && !self[:services].nil?; end |