Does Vagrant support Chef roles env_run_list?

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Does Vagrant support Chef roles env_run_list?

Andrew Havens
I am in the process of setting up a vagrant environment for development. I am using chef-solo for provisioning. I am trying to set it up in a way that I can easily share cookbooks & etc between development (Vagrant) and production environments. I am using chef roles which has been working well so that my shared configuration is outside of the Vagrantfile. However, now I need to apply some vagrant specific provisioning. I noticed that chef has a feature for creating different run lists for different environments: http://wiki.opscode.com/display/chef/Roles#Roles-env_run_lists

So my question is does Vagrant support this, i.e. what is the environment that vagrant would declare itself as?

Thanks,

Andrew

--
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: Does Vagrant support Chef roles env_run_list?

Nilesh
Here is an example Vagrantfile segment...Look for the chef solo
section in your vagrantfile

  # config.vm.provision :chef_solo do |chef|
  #   chef.cookbooks_path = "../../chef/cookbooks"
  #   chef.roles_path = "../../chef/roles"
  #   chef.data_bags_path = "../../chef/data_bags"
  #   chef.add_recipe "mysql"
  #   chef.add_role "web"
  #
  #   # You may also specify custom JSON attributes:
  #   chef.json = { :mysql_password => "foo" }
  # end

Here you will the line that contains chef.add_role "web" which is
where this particular VM is being assigned the "web" role and would
take on the role you define in the roles file located in your
chef.roles_path

An example folder structure might look like this. focus on the chef
subfolder layout folder and the .chef subfolder

├───.chef
│   └───bootstrap
├───boxes
├───chef
│   ├───data_bags
│   │   ├───dna
│   │   ├───mysql
│   │   └───postgresql
│   ├───environments
│   ├───roles
│   └───site-cookbooks
│       ├───main
│       │   ├───attributes
│       │   ├───definitions
│       │   ├───files
│       │   │   └───default
│       │   ├───libraries
│       │   ├───providers
│       │   ├───recipes
│       │   ├───resources
│       │   └───templates
│       │       └───default
│       └───rails-lastmile
│           ├───attributes
│           ├───recipes
│           └───templates
│               └───default
├───definitions
│   └───mybox
├───instances
│   └───cluster
├───iso
└───notes


On Fri, Feb 22, 2013 at 2:09 PM, Andrew Havens <[hidden email]> wrote:

> I am in the process of setting up a vagrant environment for development. I
> am using chef-solo for provisioning. I am trying to set it up in a way that
> I can easily share cookbooks & etc between development (Vagrant) and
> production environments. I am using chef roles which has been working well
> so that my shared configuration is outside of the Vagrantfile. However, now
> I need to apply some vagrant specific provisioning. I noticed that chef has
> a feature for creating different run lists for different environments:
> http://wiki.opscode.com/display/chef/Roles#Roles-env_run_lists
>
> So my question is does Vagrant support this, i.e. what is the environment
> that vagrant would declare itself as?
>
> Thanks,
>
> Andrew
>
> --
> You received this message because you are subscribed to the Google Groups
> "Vagrant" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [hidden email].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

--
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.


Reply | Threaded
Open this post in threaded view
|

Re: Does Vagrant support Chef roles env_run_list?

Andrew Havens
Thanks, but that's the part that I already have. I'm wondering about that environments directory that you have listed in your directory structure. How can I take advantage of that and separate my vagrant specific setup from my production setup?

--Andrew

On Friday, February 22, 2013 3:14:09 PM UTC-8, Nilesh L wrote:
Here is an example Vagrantfile segment...Look for the chef solo
section in your vagrantfile

  # config.vm.provision :chef_solo do |chef|
  #   chef.cookbooks_path = "../../chef/cookbooks"
  #   chef.roles_path = "../../chef/roles"
  #   chef.data_bags_path = "../../chef/data_bags"
  #   chef.add_recipe "mysql"
  #   chef.add_role "web"
  #
  #   # You may also specify custom JSON attributes:
  #   chef.json = { :mysql_password => "foo" }
  # end

Here you will the line that contains chef.add_role "web" which is
where this particular VM is being assigned the "web" role and would
take on the role you define in the roles file located in your
chef.roles_path

An example folder structure might look like this. focus on the chef
subfolder layout folder and the .chef subfolder

├───.chef
│   └───bootstrap
├───boxes
├───chef
│   ├───data_bags
│   │   ├───dna
│   │   ├───mysql
│   │   └───postgresql
│   ├───environments
│   ├───roles
│   └───site-cookbooks
│       ├───main
│       │   ├───attributes
│       │   ├───definitions
│       │   ├───files
│       │   │   └───default
│       │   ├───libraries
│       │   ├───providers
│       │   ├───recipes
│       │   ├───resources
│       │   └───templates
│       │       └───default
│       └───rails-lastmile
│           ├───attributes
│           ├───recipes
│           └───templates
│               └───default
├───definitions
│   └───mybox
├───instances
│   └───cluster
├───iso
└───notes


On Fri, Feb 22, 2013 at 2:09 PM, Andrew Havens <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="ZYvet_UWOy4J">and...@...> wrote:

> I am in the process of setting up a vagrant environment for development. I
> am using chef-solo for provisioning. I am trying to set it up in a way that
> I can easily share cookbooks & etc between development (Vagrant) and
> production environments. I am using chef roles which has been working well
> so that my shared configuration is outside of the Vagrantfile. However, now
> I need to apply some vagrant specific provisioning. I noticed that chef has
> a feature for creating different run lists for different environments:
> http://wiki.opscode.com/display/chef/Roles#Roles-env_run_lists
>
> So my question is does Vagrant support this, i.e. what is the environment
> that vagrant would declare itself as?
>
> Thanks,
>
> Andrew
>
> --
> You received this message because you are subscribed to the Google Groups
> "Vagrant" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="ZYvet_UWOy4J">vagrant-up+...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

--
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: Does Vagrant support Chef roles env_run_list?

Teemu Matilainen
In reply to this post by Andrew Havens
On Fri, Feb 22, 2013 at 7:09 PM, Andrew Havens <[hidden email]> wrote:
> I am in the process of setting up a vagrant environment for development. I
> am using chef-solo for provisioning.

chef-solo does not support environments yet, but will do in the future:
http://tickets.opscode.com/browse/CHEF-3356

> So my question is does Vagrant support this, i.e. what is the environment
> that vagrant would declare itself as?

"_default".

--
Teemu

--
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.


Reply | Threaded
Open this post in threaded view
|

Re: Does Vagrant support Chef roles env_run_list?

Andrew Havens
On Monday, February 25, 2013 5:08:29 AM UTC-8, Teemu Matilainen wrote:
chef-solo does not support environments yet, but will do in the future:
http://tickets.opscode.com/browse/CHEF-3356

Thanks Teemu. Good to know. 

--
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: Does Vagrant support Chef roles env_run_list?

Andrew Havens
In reply to this post by Andrew Havens


On Friday, February 22, 2013 2:09:49 PM UTC-8, Andrew Havens wrote:
I am trying to set it up in a way that I can easily share cookbooks & etc between development (Vagrant) and production environments.

Even though chef-solo does not yet support env_run_lists, I found a way to accomplish the Vagrant specific setup while still using roles. The way Vagrant handles configuration is that it will override the attributes and append recipes:

    web.vm.provision :chef_solo do |chef|
      chef.cookbooks_path = "chef/cookbooks"
      chef.roles_path = "chef/roles"
      chef.add_role "web"
      chef.json = {
        :apache => {
          :user => 'vagrant',
          :group => 'vagrant',
        }
      }
      chef.add_recipe 'my-development::apache-vhost'
    end

The rest of my configuration takes place in the role file, but now my development specific configuration lives in a separate cookbook/recipe which is added to the end of the run list defined in the role file.

--
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.