Setting an environment for a chef-solo run

Hello,

I want to test a cookbook in Vagrant, using chef-solo for provisioning.
According to the Chef documentation chef-solo can use environments
(http://docs.opscode.com/chef_solo.html#environments).

How do I specify an environment, so that chef-solo will use it? The
documentation is not really clear on this. I want that
node.chef_environment returns ‘stage’ on the chef-solo run, but with
chef-solo node.chef_environment seems always to be ‘_default’.

Sorry if this is a FAQ but I did not find a usefull pointers/examples yet.

Best regards and thanks,
Tom

chef-solo doesn't use environments I use this to get around it.

environment = "vagrant"
environment = node.chef_environment if node.chef_environment != "_default"

Let me know if you have any questions.

On Tue, Sep 10, 2013 at 9:21 AM, Thomas Seliger neovatar@gmail.com wrote:

Hello,

I want to test a cookbook in Vagrant, using chef-solo for provisioning.
According to the Chef documentation chef-solo can use environments
(chef-solo).

How do I specify an environment, so that chef-solo will use it? The
documentation is not really clear on this. I want that
node.chef_environment returns 'stage' on the chef-solo run, but with
chef-solo node.chef_environment seems always to be '_default'.

Sorry if this is a FAQ but I did not find a usefull pointers/examples yet.

Best regards and thanks,
Tom

On Tuesday, September 10, 2013 at 7:34 AM, Nic Grayson wrote:

chef-solo doesn't use environments I use this to get around it.

environment = "vagrant"
environment = node.chef_environment if node.chef_environment != "_default"

Let me know if you have any questions.

On Tue, Sep 10, 2013 at 9:21 AM, Thomas Seliger <neovatar@gmail.com (mailto:neovatar@gmail.com)> wrote:

Hello,

I want to test a cookbook in Vagrant, using chef-solo for provisioning.
According to the Chef documentation chef-solo can use environments
(chef-solo).

How do I specify an environment, so that chef-solo will use it? The
documentation is not really clear on this. I want that
node.chef_environment returns 'stage' on the chef-solo run, but with
chef-solo node.chef_environment seems always to be '_default'.

Sorry if this is a FAQ but I did not find a usefull pointers/examples yet.

Best regards and thanks,
Tom

This feature was just added: https://tickets.opscode.com/browse/CHEF-3356

You need 11.6.0+ to use it.

To actually set the environment, I think you need to put something like environment "test" in your solo.rb config file.

--
Daniel DeLeo