Class: AvstCloud::CapistranoDeploymentTask
- Defined in:
- lib/avst-cloud/task.rb
Instance Method Summary collapse
- #execute(server) ⇒ Object
-
#initialize(git, branch, server_tmp_folder = "/tmp/avst_cloud_tmp_#{Time.now.to_i}", reference = nil, custom_provisioning_commands = [], puppet_runner = nil, puppet_runner_prepare = nil, destination_folder = '/var/opt/puppet', avst_cloud_config_dir = 'config', download_dependencies_command = nil) ⇒ CapistranoDeploymentTask
constructor
A new instance of CapistranoDeploymentTask.
Methods included from Logging
included, logger, #logger, logger=, mask_message, show_passwords=
Constructor Details
#initialize(git, branch, server_tmp_folder = "/tmp/avst_cloud_tmp_#{Time.now.to_i}", reference = nil, custom_provisioning_commands = [], puppet_runner = nil, puppet_runner_prepare = nil, destination_folder = '/var/opt/puppet', avst_cloud_config_dir = 'config', download_dependencies_command = nil) ⇒ CapistranoDeploymentTask
Returns a new instance of CapistranoDeploymentTask.
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
# File 'lib/avst-cloud/task.rb', line 179 def initialize(git, branch, server_tmp_folder = "/tmp/avst_cloud_tmp_#{Time.now.to_i}", reference = nil, custom_provisioning_commands = [], puppet_runner = nil, puppet_runner_prepare = nil, destination_folder = '/var/opt/puppet', avst_cloud_config_dir = 'config', download_dependencies_command = nil) unless git and (branch or reference) logger.debug "You have to provide git repo url #{git} and git branch #{branch} or git tag reference #{reference}".red raise "You have to provide git repo url #{git} and git branch #{branch} or git tag reference #{reference}" end @git = git @branch = branch @server_tmp_folder = server_tmp_folder @reference = reference @custom_provisioning_commands = custom_provisioning_commands || [] @puppet_runner = puppet_runner @download_dependencies_command = download_dependencies_command @puppet_runner_prepare = puppet_runner_prepare @destination_folder = destination_folder || '/var/opt/puppet' @avst_cloud_config_dir = avst_cloud_config_dir || 'config' end |
Instance Method Details
#execute(server) ⇒ Object
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 |
# File 'lib/avst-cloud/task.rb', line 197 def execute(server) unless server.ip_address logger.error 'Can not find host'.red raise 'Can not find ip address, access_user or access_password' end unless server.access_user logger.error 'Access user not found. Please provide username for this server.'.red raise 'Access user not found. Please provide username for this server.' end unless server.access_password logger.error 'Password not found. Please provide password or pem key for this server.'.red raise 'Password not found. Please provide root_password in config. for this server.' end logger.debug "Using #{server.access_user}@#{server.ip_address} with #{Logging.mask_message(server.access_password)}" # Initiate capistrano deploy script to download the laters code and provision the server require 'capistrano/all' require 'capistrano/setup' require 'capistrano/deploy' Dir.glob("#{File.dirname __dir__}/capistrano/tasks/*.rake").each { |r| load r } # cap production deploy ENV['cap_git_repo_url'] = @git ENV['cap_branch_name'] = @branch ENV['cap_reference_name'] = @reference ENV['cap_ip_address'] = server.ip_address ENV['cap_access_password'] = server.access_password ENV['cap_access_user'] = server.access_user ENV['server_name'] = server.server_name ENV['puppet_runner'] = @puppet_runner ENV['download_dependencies_command'] = @download_dependencies_command ENV['puppet_runner_prepare'] = @puppet_runner_prepare ENV['avst_cloud_tmp_folder'] = @server_tmp_folder ENV['custom_provisioning_commands'] = @custom_provisioning_commands.to_json ENV['destination_folder'] = @destination_folder ENV['avst_cloud_config_dir'] = @avst_cloud_config_dir logger.debug "Using git #{@git} branch #{@branch} to provision #{server.ip_address}" Capistrano::Application.invoke('production') Capistrano::Application.invoke('deploy') logger.debug "You can connect to server on #{server.ip_address}" end |