Class: CemAcpt::Provision::Terraform
- Inherits:
-
Object
- Object
- CemAcpt::Provision::Terraform
- Includes:
- Logging
- Defined in:
- lib/cem_acpt/provision/terraform.rb
Constant Summary collapse
- DEFAULT_PLAN_NAME =
'testplan.tfplan'
Constants included from Logging
Instance Attribute Summary collapse
-
#environment ⇒ Object
readonly
Returns the value of attribute environment.
-
#working_dir ⇒ Object
readonly
Returns the value of attribute working_dir.
Instance Method Summary collapse
- #destroy ⇒ Object
-
#initialize(config, provision_data) ⇒ Terraform
constructor
A new instance of Terraform.
- #provision ⇒ Object
Methods included from Logging
current_log_config, #current_log_config, current_log_format, #current_log_format, current_log_level, #current_log_level, included, logger, #logger, new_log_config, #new_log_config, new_log_formatter, #new_log_formatter, new_log_level, #new_log_level, new_logger, #new_logger
Constructor Details
#initialize(config, provision_data) ⇒ Terraform
Returns a new instance of Terraform.
18 19 20 21 22 23 24 |
# File 'lib/cem_acpt/provision/terraform.rb', line 18 def initialize(config, provision_data) @config = config @provision_data = provision_data @backend = new_backend(@provision_data[:test_data].first[:test_name]) @environment = new_environment(@config) @working_dir = nil end |
Instance Attribute Details
#environment ⇒ Object (readonly)
Returns the value of attribute environment.
16 17 18 |
# File 'lib/cem_acpt/provision/terraform.rb', line 16 def environment @environment end |
#working_dir ⇒ Object (readonly)
Returns the value of attribute working_dir.
16 17 18 |
# File 'lib/cem_acpt/provision/terraform.rb', line 16 def working_dir @working_dir end |
Instance Method Details
#destroy ⇒ Object
38 39 40 41 42 43 |
# File 'lib/cem_acpt/provision/terraform.rb', line 38 def destroy terraform_destroy(formatted_vars) logger.verbose('Terraform') { "Deleting old working directory #{working_dir}" } FileUtils.rm_rf(working_dir) @working_dir = nil end |
#provision ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/cem_acpt/provision/terraform.rb', line 26 def provision logger.info('Terraform') { 'Provisioning nodes...' } @working_dir = new_working_dir validate_working_dir! terraform_configure_logging terraform_init terraform_plan(formatted_vars, DEFAULT_PLAN_NAME) terraform_apply(DEFAULT_PLAN_NAME) JSON.parse(terraform_output('instance_name_ip', json: true)) end |