Class: Kitchen::Provisioner::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/kitchen/provisioner/chef_zero_nodes.rb

Instance Method Summary collapse

Instance Method Details

#call(state) ⇒ Object

ChefZeroNodes needs to access to provision of the instance without invoking the behavior of Base#call because we need to add additional command after chef_client run complete.

Parameters:

  • state (Hash)

    mutable instance state

Raises:

  • (ActionFailed)

    if the action could not be completed



122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/kitchen/provisioner/chef_zero_nodes.rb', line 122

def call(state)
  create_sandbox
  sandbox_dirs = Dir.glob(File.join(sandbox_path, '*'))

  instance.transport.connection(state) do |conn|
    conn.execute(install_command)
    conn.execute(init_command)
    info("Transferring files to #{instance.to_str}")
    conn.upload(sandbox_dirs, config[:root_path])
    debug('Transfer complete')
    conn.execute(prepare_command)
    conn.execute(run_command)
    # Download node json object generated by chef_client
    int_node_file = windows_os? ? win_int_node_file : unix_int_node_file
    info("Transferring #{int_node_file} " \
         "from instance to #{ext_node_file}")
    conn.download(int_node_file, ext_node_file)
    debug('Transfer complete')
  end
rescue Kitchen::Transport::TransportFailed => ex
  raise ActionFailed, ex.message
ensure
  cleanup_sandbox
end