Class: CemAcpt::Provision::OsData
- Inherits:
-
Object
- Object
- CemAcpt::Provision::OsData
- Extended by:
- Logging
- Includes:
- Logging
- Defined in:
- lib/cem_acpt/provision/terraform/os_data.rb
Overview
Base class for OS-specific provisioning data
Constant Summary
Constants included from Logging
Instance Attribute Summary collapse
-
#base_provision_directory ⇒ Object
Returns the value of attribute base_provision_directory.
Class Method Summary collapse
-
.use_for?(test_name) ⇒ Boolean
Determines if this OsData implementation should be used for the given test name.
-
.valid_names ⇒ Array<String>
Returns an array of valid OS names that this class can handle.
-
.valid_versions ⇒ Array<String>
Returns an array of valid OS versions that this class can handle.
Instance Method Summary collapse
-
#destination_provision_directory ⇒ String
The path to the destination provision directory on the provisioned nodes.
-
#goss_files ⇒ Array<String>
An array of filenames for Goss test files that should be included in the provision directory.
-
#implementation_name ⇒ String
The name of the OsData implementation, derived from the class name.
-
#initialize(config, provision_data) ⇒ OsData
constructor
Initializes a new instance of the OsData class with the given configuration and provision data.
-
#provision_commands ⇒ Array<String>
An array of shell commands to be run on the provisioned nodes to set up the necessary environment for running the Puppet manifest.
-
#provision_directory ⇒ String
The path to the provision directory for this OsData implementation, which is a subdirectory of the base provision directory named after the implementation.
-
#puppet_bin_path ⇒ String
Returns the path to the Puppet binary on the provisioned nodes.
-
#puppet_manifest_file ⇒ String
The filename of the Puppet manifest to be used for provisioning.
-
#remote_module_package_name ⇒ String
The name of the remote package file that will be created on the provisioned nodes for installing the Puppet module.
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, verbose?, verbose?
Constructor Details
#initialize(config, provision_data) ⇒ OsData
Initializes a new instance of the OsData class with the given configuration and provision data.
50 51 52 53 54 |
# File 'lib/cem_acpt/provision/terraform/os_data.rb', line 50 def initialize(config, provision_data) @config = config @provision_data = provision_data @base_provision_directory = @config.get('terraform.dir') end |
Instance Attribute Details
#base_provision_directory ⇒ Object
Returns the value of attribute base_provision_directory.
44 45 46 |
# File 'lib/cem_acpt/provision/terraform/os_data.rb', line 44 def base_provision_directory @base_provision_directory end |
Class Method Details
.use_for?(test_name) ⇒ Boolean
Determines if this OsData implementation should be used for the given test name. This method extracts the OS name and version from the test name using a regular expression, and checks if they match the valid names and versions defined by the subclass. The test name is expected to be in the format ‘<prefix>_osname-version`, where osname is the name of the operating system and version is the version number. For example, a test name of test_ubuntu-20 would indicate an Ubuntu OS with version 20.
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/cem_acpt/provision/terraform/os_data.rb', line 17 def self.use_for?(test_name) name_ver = test_name.match(%r{^\w+_(\w+)-(\d+).*}) return false unless name_ver && name_ver.length == 3 if valid_versions.include?(name_ver[2]) || valid_versions.include?(name_ver[2].to_s) return true if valid_names.include?(name_ver[1]) end false end |
.valid_names ⇒ Array<String>
Returns an array of valid OS names that this class can handle. This method should be implemented by subclasses to specify which OS names they can handle. The OS name is typically extracted from the test name and used to determine which OS-specific data class to use for provisioning.
32 33 34 |
# File 'lib/cem_acpt/provision/terraform/os_data.rb', line 32 def self.valid_names raise NotImplementedError end |
.valid_versions ⇒ Array<String>
Returns an array of valid OS versions that this class can handle. This method should be implemented by subclasses to specify which OS versions they can handle. The OS version is typically extracted from the test name and used to determine which OS-specific data class to use for provisioning.
40 41 42 |
# File 'lib/cem_acpt/provision/terraform/os_data.rb', line 40 def self.valid_versions raise NotImplementedError end |
Instance Method Details
#destination_provision_directory ⇒ String
Returns The path to the destination provision directory on the provisioned nodes. This method should be implemented by subclasses to specify the correct path for the specific OS they handle.
87 88 89 |
# File 'lib/cem_acpt/provision/terraform/os_data.rb', line 87 def destination_provision_directory raise NotImplementedError end |
#goss_files ⇒ Array<String>
Returns An array of filenames for Goss test files that should be included in the provision directory.
100 101 102 |
# File 'lib/cem_acpt/provision/terraform/os_data.rb', line 100 def goss_files Dir.glob(File.join(provision_directory, 'goss', '*.yaml')).map { |f| File.basename(f) } end |
#implementation_name ⇒ String
Returns The name of the OsData implementation, derived from the class name.
75 76 77 |
# File 'lib/cem_acpt/provision/terraform/os_data.rb', line 75 def implementation_name self.class.to_s.downcase.split('::').last end |
#provision_commands ⇒ Array<String>
Returns An array of shell commands to be run on the provisioned nodes to set up the necessary environment for running the Puppet manifest. This method should be implemented by subclasses to specify the correct commands for the specific OS they handle.
94 95 96 |
# File 'lib/cem_acpt/provision/terraform/os_data.rb', line 94 def provision_commands raise NotImplementedError end |
#provision_directory ⇒ String
Returns The path to the provision directory for this OsData implementation, which is a subdirectory of the base provision directory named after the implementation.
81 82 83 |
# File 'lib/cem_acpt/provision/terraform/os_data.rb', line 81 def provision_directory File.join(base_provision_directory, implementation_name) end |
#puppet_bin_path ⇒ String
Returns the path to the Puppet binary on the provisioned nodes. This method should be implemented by subclasses to specify the correct path to the Puppet binary for the specific OS they handle.
59 60 61 |
# File 'lib/cem_acpt/provision/terraform/os_data.rb', line 59 def puppet_bin_path raise NotImplementedError end |
#puppet_manifest_file ⇒ String
Returns The filename of the Puppet manifest to be used for provisioning.
64 65 66 |
# File 'lib/cem_acpt/provision/terraform/os_data.rb', line 64 def puppet_manifest_file 'manifest.pp' end |
#remote_module_package_name ⇒ String
Returns The name of the remote package file that will be created on the provisioned nodes for installing the Puppet module.
70 71 72 |
# File 'lib/cem_acpt/provision/terraform/os_data.rb', line 70 def remote_module_package_name 'puppet-module.tar.gz' end |