New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load required chef_client options from Knife config #1592

Closed
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
5 participants
@justincampbell
Copy link
Member

justincampbell commented Apr 12, 2013

Adds a chef_config/knife method to both chef solo and chef client provisioners, which returns a hash with symbolized keys. For instance, I have a file at ~/.chef/knife.rb, which I think looks like most user's Knife config:

current_dir = File.dirname(__FILE__)
validation_key  "#{current_dir}/justincampbell-validator.pem"
chef_server_url "https://api.opscode.com/organizations/justincampbell"

This causes knife to return a hash of:

{
  :validation_key => "~/.chef/justincampbell-validator.pem",
  :chef_server_url => "https://api.opscode.com/organizations/justincampbell"
}

You can now omit these options in a :chef_client provisioner block:

config.vm.provision :chef_client do |chef|
  chef.run_list = ["recipe[my_cookbook::default]"]
end

You could potentially also use knife[:key] in your Vagrantfile.

Load required chef_client options from Knife config
Adds a chef_config/knife method to both chef solo and chef client
provisioners, which returns a hash with symbolized keys. For instance, I
have a file at `~/.chef/knife.rb`, which I think looks like most user's
Knife config:

```rb
current_dir = File.dirname(__FILE__)
validation_key  "#{current_dir}/justincampbell-validator.pem"
chef_server_url "https://api.opscode.com/organizations/justincampbell"
```

This causes `knife` to return a hash of:

```rb
{
  :validation_key => "~/.chef/justincampbell-validator.pem",
  :chef_server_url => "https://api.opscode.com/organizations/justincampbell"
}
```

You can now omit these options in a `:chef_client` provisioner block:

```rb
config.vm.provision :chef_client do |chef|
  chef.run_list = ["recipe[my_cookbook::default]"]
end
```

You could potentially also use knife[:key] in your Vagrantfile.
@justincampbell

This comment has been minimized.

Copy link
Member

justincampbell commented Apr 12, 2013

@mitchellh I have a test for this too but I had no idea where to put it

@justinforce

This comment has been minimized.

Copy link

justinforce commented Apr 12, 2013

I like this idea very much.

@knuckolls

This comment has been minimized.

Copy link

knuckolls commented Apr 17, 2013

This should be merged. I think it's the right way to do it.

@jeffbyrnes

This comment has been minimized.

Copy link

jeffbyrnes commented May 27, 2013

👍

@mitchellh

This comment has been minimized.

Copy link
Member

mitchellh commented Sep 2, 2013

I actually really like this but I'm not a big fan of just evaling the Chef configuration. If you can get Knife to have a export option or something that outputs it in a machine parseable format, then I'd be happy to merge this in. But... loading random ruby files and evaling, I'm not such a big fan of. Sorry.

@mitchellh mitchellh closed this Sep 2, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment