Sha256: 4fac8f5505b7051fedf760d0a1f2d401efaac34fa4a351dba2cd90585b280dae
Contents?: true
Size: 1.8 KB
Versions: 2
Compression:
Stored size: 1.8 KB
Contents
require 'tempfile' require_relative '../helper' require_relative '../windows_machine' module VagrantWindows module Provisioners # Builds scripts and ultimately the command to execute Chef solo or Chef client # on Windows guests using a scheduled task. class ChefCommandBuilder include VagrantWindows::Helper def initialize(windows_machine, chef_config, client_type) @windows_machine = windows_machine @config = chef_config if client_type != :solo && client_type != :client raise 'Invalid client_type, expected solo or client' end @client_type = client_type end def run_chef_command() options = { :command => "#{chef_binary_path} #{chef_arguments}", :username => @windows_machine.winrm_config.username, :password => @windows_machine.winrm_config.password } return VagrantWindows.load_script_template('elevated_shell.ps1', :options => options) end def chef_arguments() command_args = @config.arguments ? @config.arguments : '' chef_path = provisioning_path("#{@client_type}.rb") chef_dna_path = provisioning_path('dna.json') chef_arguments = "-c #{chef_path}" chef_arguments << " -j #{chef_dna_path}" chef_arguments << " #{command_args}" chef_arguments.strip end # Returns the path to the Chef binary, taking into account the # `binary_path` configuration option. def chef_binary_path() binary = "chef-#{@client_type}" return binary if !@config.binary_path return win_friendly_path(File.join(@config.binary_path, binary)) end def provisioning_path(file_name) win_friendly_path("#{@config.provisioning_path}/#{file_name}") end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
vagrant-windows-1.7.0.pre.2 | lib/vagrant-windows/provisioners/chef_command_builder.rb |
vagrant-windows-1.7.0.pre.1 | lib/vagrant-windows/provisioners/chef_command_builder.rb |