Class: Kitchen::Provisioner::ChefSolo
- Defined in:
- lib/kitchen/provisioner/chef_solo.rb
Overview
Chef Solo provisioner.
Instance Attribute Summary
Attributes included from Configurable
Instance Method Summary collapse
-
#create_sandbox ⇒ Object
Creates a temporary directory on the local workstation into which provisioner related files and directories can be copied or created.
- #modern? ⇒ Boolean
-
#run_command ⇒ String
Generates a command string which will invoke the main provisioner command on the prepared instance.
Methods inherited from ChefBase
#init_command, #initialize, #install_command
Methods inherited from Base
#call, #cleanup_sandbox, #init_command, #initialize, #install_command, kitchen_provisioner_api_version, #prepare_command, #sandbox_path
Methods included from Logging
#banner, #debug, #error, #fatal, #info, #warn
Methods included from Configurable
#[], #bourne_shell?, #calculate_path, #config_keys, #diagnose, #diagnose_plugin, #finalize_config!, included, #name, #powershell_shell?, #remote_path_join, #unix_os?, #verify_dependencies, #windows_os?
Constructor Details
This class inherits a constructor from Kitchen::Provisioner::ChefBase
Instance Method Details
#create_sandbox ⇒ Object
Creates a temporary directory on the local workstation into which provisioner related files and directories can be copied or created. The contents of this directory will be copied over to the instance before invoking the provisioner's run command. After this method completes, it is expected that the contents of the sandbox is complete and ready for copy to the remote instance.
Note: any subclasses would be well advised to call super first when overriding this method, for example:
40 41 42 43 |
# File 'lib/kitchen/provisioner/chef_solo.rb', line 40 def create_sandbox super prepare_solo_rb end |
#modern? ⇒ Boolean
45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/kitchen/provisioner/chef_solo.rb', line 45 def modern? version = config[:require_chef_omnibus] case version when nil, false, true, 11, "11", "latest" true else if Gem::Version.correct?(version) Gem::Version.new(version) >= Gem::Version.new("11.0") ? true : false else true end end end |
#run_command ⇒ String
Generates a command string which will invoke the main provisioner
command on the prepared instance. If no work is required, then nil
will be returned.
rubocop:disable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity, Metrics/AbcSize
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/kitchen/provisioner/chef_solo.rb', line 62 def run_command config[:log_level] = "info" if !modern? && config[:log_level] = "auto" cmd = sudo(config[:chef_solo_path]).dup .tap { |str| str.insert(0, "& ") if powershell_shell? } args = [ "--config #{remote_path_join(config[:root_path], 'solo.rb')}", "--log_level #{config[:log_level]}", "--no-color", "--json-attributes #{remote_path_join(config[:root_path], 'dna.json')}", ] args << " --force-formatter" if modern? args << "--logfile #{config[:log_file]}" if config[:log_file] args << "--profile-ruby" if config[:profile_ruby] args << "--legacy-mode" if config[:legacy_mode] prefix_command( wrap_shell_code( [cmd, *args].join(" ") .tap { |str| str.insert(0, reload_ps1_path) if windows_os? } ) ) end |