Class: Vagrant::Provisioners::Chef

Inherits:
Base
  • Object
show all
Defined in:
lib/vagrant/provisioners/chef.rb

Overview

This class is a base class where the common functinality shared between chef-solo and chef-client provisioning are stored. This is **not an actual provisioner**. Instead, ChefSolo or ChefServer should be used.

Direct Known Subclasses

ChefServer, ChefSolo

Defined Under Namespace

Classes: ChefConfig

Instance Attribute Summary

Attributes inherited from Base

#env

Instance Method Summary collapse

Methods inherited from Base

#initialize, #provision!

Methods included from Util

#error_and_exit, included, #logger, #wrap_output

Constructor Details

This class inherits a constructor from Vagrant::Provisioners::Base

Instance Method Details

#chown_provisioning_folderObject



73
74
75
76
77
78
79
# File 'lib/vagrant/provisioners/chef.rb', line 73

def chown_provisioning_folder
  logger.info "Setting permissions on chef provisioning folder..."
  env.ssh.execute do |ssh|
    ssh.exec!("sudo mkdir -p #{env.config.chef.provisioning_path}")
    ssh.exec!("sudo chown #{env.config.ssh.username} #{env.config.chef.provisioning_path}")
  end
end

#prepareObject



69
70
71
# File 'lib/vagrant/provisioners/chef.rb', line 69

def prepare
  raise Actions::ActionException.new(:chef_base_invalid_provisioner)
end

#setup_jsonObject



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/vagrant/provisioners/chef.rb', line 81

def setup_json
  logger.info "Generating chef JSON and uploading..."

  # Set up initial configuration
  data = {
    :config => env.config,
    :directory => env.config.vm.project_directory,
  }

  # And wrap it under the "vagrant" namespace
  data = { :vagrant => data }

  # Merge with the "extra data" which isn't put under the
  # vagrant namespace by default
  data.merge!(env.config.chef.json)

  json = data.to_json

  env.ssh.upload!(StringIO.new(json), File.join(env.config.chef.provisioning_path, "dna.json"))
end