Class: InstanceAgent::CodeDeployPlugin::Installer
- Inherits:
-
Object
- Object
- InstanceAgent::CodeDeployPlugin::Installer
- Defined in:
- lib/instance_agent/codedeploy_plugin/installer.rb
Overview
Manages install and cleanup files. Also generates and executes install instructions based on the files section of the application specification file.
Instance Attribute Summary collapse
-
#deployment_archive_dir ⇒ Object
readonly
Returns the value of attribute deployment_archive_dir.
-
#deployment_instructions_dir ⇒ Object
readonly
Returns the value of attribute deployment_instructions_dir.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ Installer
constructor
A new instance of Installer.
- #install(deployment_group_id, application_specification) ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Installer
Returns a new instance of Installer.
14 15 16 17 18 19 20 21 22 |
# File 'lib/instance_agent/codedeploy_plugin/installer.rb', line 14 def initialize(opts = {}) raise "the deployment_archive_dir option is required" if opts[:deployment_archive_dir].nil? raise "the deployment_instructions_dir option is required" if opts[:deployment_instructions_dir].nil? @deployment_archive_dir = opts[:deployment_archive_dir] @deployment_instructions_dir = opts[:deployment_instructions_dir] end |
Instance Attribute Details
#deployment_archive_dir ⇒ Object (readonly)
Returns the value of attribute deployment_archive_dir.
11 12 13 |
# File 'lib/instance_agent/codedeploy_plugin/installer.rb', line 11 def deployment_archive_dir @deployment_archive_dir end |
#deployment_instructions_dir ⇒ Object (readonly)
Returns the value of attribute deployment_instructions_dir.
12 13 14 |
# File 'lib/instance_agent/codedeploy_plugin/installer.rb', line 12 def deployment_instructions_dir @deployment_instructions_dir end |
Instance Method Details
#install(deployment_group_id, application_specification) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/instance_agent/codedeploy_plugin/installer.rb', line 24 def install(deployment_group_id, application_specification) cleanup_file = File.join(deployment_instructions_dir, "#{deployment_group_id}-cleanup") if File.exists?(cleanup_file) InstallInstruction.parse_remove_commands(File.read(cleanup_file)).each do |cmd| cmd.execute end FileUtils.rm(cleanup_file) end instructions = generate_instructions(application_specification) install_file = File.join(deployment_instructions_dir, "#{deployment_group_id}-install.json") File.open(install_file, "w") do |f| f.write(instructions.to_json) end File.open(cleanup_file, "w") do |f| instructions.each do |cmd| cmd.execute(f) end end end |