Skip to content
This repository has been archived by the owner on May 10, 2018. It is now read-only.

chef provision docs don't show some features of ChefDK::ProvisioningData.context #768

Open
danielsdeleo opened this issue Dec 4, 2015 · 0 comments

Comments

@danielsdeleo
Copy link
Contributor

Upstream bug: chef-boneyard/chef-dk#618

In particular: in order for the chef provision -d (destroy) option to work, the user must set the action on machine resources to ChefDK::ProvisioningData.context.action. An example of this is provided in https://www.chef.io/blog/2015/08/18/policyfiles-a-guided-tour/ copied below:

context = ChefDK::ProvisioningData.context

# Set the port dynamically via the command line:
target_port = context.opts.port

with_driver 'vagrant:~/.vagrant.d/boxes' do

  options = {
    vagrant_options: {
      'vm.box' => 'opscode-ubuntu-14.04',
      'vm.network' => ":forwarded_port, guest: 80, host: #{target_port}"
    },
    convergence_options: context.convergence_options
  }


  machine context.node_name do
    machine_options(options)

    # This forces a chef run every time, which is sensible for `chef provision`
    # use cases.
    converge(true)
    action(context.action)
  end
end

By default, ChefDK::ProvisioningData.context.action will be :converge, but if the user passes the -d option to chef provision, ChefDK::ProvisioningData.context.action will be set to :destroy.

The relevant code for this behavior is here:

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant