Module: Maestro
- Defined in:
- lib/maestro.rb,
lib/maestro/node.rb,
lib/maestro/role.rb,
lib/maestro/cloud.rb,
lib/maestro/railtie.rb,
lib/maestro/validator.rb,
lib/maestro/operating_system.rb,
lib/maestro/operating_system/debian.rb,
lib/maestro/operating_system/fedora.rb,
lib/maestro/operating_system/ubuntu.rb,
lib/maestro/operating_system/cent_os.rb,
lib/maestro/cloud/aws.rb,
lib/maestro/cloud/aws.rb,
lib/maestro/cloud/aws.rb,
lib/maestro/cloud/aws.rb
Defined Under Namespace
Modules: Cloud, Node, OperatingSystem, Validator Classes: Railtie, Role
Constant Summary collapse
- MAESTRO_DIR_ENV_VAR =
ENV key used to point to a Maestro configuration directory
'MAESTRO_DIR'
- MAESTRO_RAILS_CONFIG_DIRECTORY =
Directory underneath RAILS_ROOT where Maestro expects to find config files
'/config/maestro'
- MAESTRO_RAILS_LOG_DIRECTORY =
Directory underneath RAILS_ROOT where Maestro log files will be written
'/log/maestro'
- MAESTRO_CHEF_ARCHIVE =
Name of the Maestro Chef assets archive
'maestro_chef_assets.tar.gz'
Class Method Summary collapse
-
.chef_archive ⇒ Object
Creates a .tar.gz file containing the Chef cookbooks/ and roles/ directories within the maestro config directory, and returns the path to the file.
-
.clouds ⇒ Object
Returns a Hash of Clouds defined in the Maestro clouds configuration directory.
-
.create_config_dirs ⇒ Object
Creates the Maestro config directory structure.
-
.create_log_dirs ⇒ Object
Creates the Maestro log directories.
-
.log_directory ⇒ Object
Returns the top level log directory.
-
.maestro_log_directory ⇒ Object
Returns the maestro log directory.
-
.validate_configs ⇒ Object
Validates your maestro configs.
Class Method Details
.chef_archive ⇒ Object
Creates a .tar.gz file containing the Chef cookbooks/ and roles/ directories within the maestro config directory, and returns the path to the file
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
# File 'lib/maestro.rb', line 135 def self.chef_archive require 'tempfile' require 'zlib' require 'archive/tar/minitar' dir = nil if rails? dir = rails_maestro_config_dir elsif ENV.has_key? MAESTRO_DIR_ENV_VAR dir = standalone_maestro_config_dir else raise "Maestro not configured correctly. Either RAILS_ROOT, Rails.root, or ENV['#{MAESTRO_DIR_ENV_VAR}'] must be defined" end temp_file = Dir.tmpdir + "/" + MAESTRO_CHEF_ARCHIVE File.delete(temp_file) if File.exist?(temp_file) pwd = Dir.pwd open temp_file, 'wb' do |io| Zlib::GzipWriter.wrap io do |gzip| begin out = Archive::Tar::Minitar::Output.new(gzip) Dir.chdir(dir) # don't store full paths in archive Dir.glob("cookbooks/**/**").each do |file| Archive::Tar::Minitar.pack_file(file, out) if File.file?(file) || File.directory?(file) end Dir.glob("roles/**/**").each do |file| Archive::Tar::Minitar.pack_file(file, out) if File.file?(file) || File.directory?(file) end ensure gzip.finish end end end Dir.chdir(pwd) temp_file end |
.clouds ⇒ Object
Returns a Hash of Clouds defined in the Maestro clouds configuration directory
102 103 104 105 106 107 108 109 110 |
# File 'lib/maestro.rb', line 102 def self.clouds if rails? get_clouds(clouds_config_dir(rails_maestro_config_dir)) elsif ENV.has_key? MAESTRO_DIR_ENV_VAR get_clouds(clouds_config_dir(standalone_maestro_config_dir)) else raise "Maestro not configured correctly. Either RAILS_ROOT, Rails.root, or ENV['#{MAESTRO_DIR_ENV_VAR}'] must be defined" end end |
.create_config_dirs ⇒ Object
Creates the Maestro config directory structure. If the directories already exist, no action is taken.
In a Rails environment:
RAILS_ROOT/config/maestro
RAILS_ROOT/config/maestro/clouds
RAILS_ROOT/config/maestro/cookbooks
RAILS_ROOT/config/maestro/roles
In a standalone environment, the following directories will be created under the directory specified by the ENV environment variable:
MAESTRO_DIR/config/maestro
MAESTRO_DIR/config/maestro/clouds
MAESTRO_DIR/config/maestro/cookbooks
MAESTRO_DIR/config/maestro/roles
56 57 58 59 60 61 62 63 64 |
# File 'lib/maestro.rb', line 56 def self.create_config_dirs if rails? create_configs(rails_config_dir) elsif ENV.has_key? MAESTRO_DIR_ENV_VAR create_configs(standalone_config_dir) else raise "Maestro not configured correctly. Either RAILS_ROOT, Rails.root, or ENV['#{MAESTRO_DIR_ENV_VAR}'] must be defined" end end |
.create_log_dirs ⇒ Object
Creates the Maestro log directories. If the directories already exist, no action is taken.
In a Rails environment:
RAILS_ROOT/log/maestro
RAILS_ROOT/log/maestro/clouds
In a standalone environment, the following directories will be created under the directory specified by the ENV environment variable:
MAESTRO_DIR/log/maestro
MAESTRO_DIR/log/maestro/clouds
78 79 80 81 82 83 84 85 86 |
# File 'lib/maestro.rb', line 78 def self.create_log_dirs if rails? create_logs(rails_log_dir) elsif ENV.has_key? MAESTRO_DIR_ENV_VAR create_logs(standalone_log_dir) else raise "Maestro not configured correctly. Either RAILS_ROOT, Rails.root, or ENV['#{MAESTRO_DIR_ENV_VAR}'] must be defined" end end |
.log_directory ⇒ Object
Returns the top level log directory
113 114 115 116 117 118 119 120 121 |
# File 'lib/maestro.rb', line 113 def self.log_directory if rails? rails_log_dir elsif ENV.has_key? MAESTRO_DIR_ENV_VAR standalone_log_dir else raise "Maestro not configured correctly. Either RAILS_ROOT, Rails.root, or ENV['#{MAESTRO_DIR_ENV_VAR}'] must be defined" end end |
.maestro_log_directory ⇒ Object
Returns the maestro log directory
124 125 126 127 128 129 130 131 132 |
# File 'lib/maestro.rb', line 124 def self.maestro_log_directory if rails? rails_log_dir + "/maestro" elsif ENV.has_key? MAESTRO_DIR_ENV_VAR standalone_log_dir + "/maestro" else raise "Maestro not configured correctly. Either RAILS_ROOT, Rails.root, or ENV['#{MAESTRO_DIR_ENV_VAR}'] must be defined" end end |
.validate_configs ⇒ Object
91 92 93 94 95 96 97 98 99 |
# File 'lib/maestro.rb', line 91 def self.validate_configs if rails? validate_rails_config elsif ENV.has_key? MAESTRO_DIR_ENV_VAR validate_standalone_config else return [false, ["Maestro not configured correctly. Either RAILS_ROOT, Rails.root, or ENV['#{MAESTRO_DIR_ENV_VAR}'] must be defined"]] end end |