Hot answers tagged

57

I am going to orient this answer as if the question was "what are the advantages of chef-solo" because that's the best way I know to cover the differences between the approaches. My summary recommendation is in line with others: use a chef-server if you need to manage a dynamic, virtualized environment where you will be adding and removing nodes often. A ...


22

Disclaimer: I am one of the developers of Puppet, another tool in the space. The advantages of using Chef on a single node are the same as using it on multiple nodes: you declare how the system should be, in a form that is easy to version control, backup, audit, and change. Chef will then go ahead and make sure your system stays that way: if something ...


22

Disclosure: I work for Opscode. The major benefit of Chef Server over Solo is the ability to use search with your infrastructure. The classic example is a load balancer with web servers. The load balancer can automatically update its configuration as web servers are added and removed to the infrastructure, simply by searching for them. Solo is just that, ...


12

This question seems subjective, but I'll try to approach this answer objectively. The Chef Server provides a publishing system and search index with a RESTful API. This means you can: Distribute cookbooks for nodes through a single location that has an API, and primitives for creating version constraints, retrieval, all the things you'd probably expect ...


11

Use the directory resource to create the directory before creating the template. The trick is to also specify the recursive attribute otherwise the action will fail unless all parts of the directory but the last exist already. config_dir = "#{node[:app][:deploy_to]}/#{node[:app][:name]}/shared/config" directory config_dir do owner node[:user][:username] ...


8

The behaviour you're seeing can be explained by understanding the difference between two of the key stages in a Chef client run: compilation, and convergence. During the "compile" phase, the Chef client runs the code in your recipes to build a resource collection. This is a list of the Resources that you've told Chef to manage on your system, along with ...


7

You might (also) look into Vagrant for this. A video is showing how to use the combo of Vagrant and Chef cookbooks. And there's a dedicated page to Vagrant and Chef on the Opscode site (update 2015-01-23: page has gone...).


7

Notifications are the right way to handle this. Suppose you want to do the following: Conditionally download a file If the file is downloaded Stop apache immediately Process the file (e.g. unzip it or move it) Start apache again You would do it like this: # Define the apache service but don't do anything with it service "apache" do action :nothing ...


7

The problem is that your resources have the same name. service "apache" is not unique, so chef is de-duplicating them. Your options are to give them separate names like this service "apache stop" do service_name "apache" action :stop end # Do something service "apache start" do service_name "apache" action :start end you could also use a ...


7

Most Windows bootstrap resources are focused on Hosted Chef and using the knife-windows plugin. However this should be possible with Chef solo. If you're not building an AMI with chef-client on it then your first step is to get the Full Chef Windows installer on there. Fortunately, as I recall, winrm is enabled by default on the Windows Amazon AMIs. Take ...


7

There are plenty of good reasons to use configuration management software. While there are many different tools, I'll focus on a few of the features of Puppet (the main concepts are largely the same). Note: While you could argue that writing your own scripts could achieve the same results, presumably you'd have to write and maintain a large codebase to ...


6

I went on about in a blog post from January. Eventually, you'll have to migrate that machine, replace it, setup a new one, run a test build, etc. Also, everything is documented in one place, so anybody else who has to look at the machine can tell what is going on without having to hunt around the system. Like it says above: Every time I get another machine, ...


6

If you use chef-solo, you don't get to use knife. Knife is API client for the chef-server, with some extra utility sugar (like knife rackspace server create you've mentioned). To configure server with chef-solo, you should copy your chef repo to the server, and run chef-solo there over ssh. There is no ready-made script or knife plugin that I know of that ...


6

If you just want to configure a virtual host via nginx, it's likely you want to use the nginx cookbook. The application_nginx cookbooks is not meant to be used directly; rather it is a dependency of the application cookbook. If you are just getting started with chef I would avoid the application cookbook for now, since its use is somewhat complex. The ...


6

If all else fails, there's the old fashioned way - On Ubuntu or debian,use dpkg --get-selections to dump out a list of installed packages, and install them with dpkg --set-selections. The equivalent of this for red hat based distros is yum-debug-dump and yum-debug-restore (optionally with --install-latest). Create the same users as the source system if ...


5

Check out the knife-solo plugin, which can automatically install chef-solo on your remote server, upload your cookbooks onto it, and then run chef-solo. It basically automates what other folks who've answered this question have suggested doing.


5

This will do the trick: yml_string = YAML::dump(node['cfn']['environment'].to_hash)


5

I just encountered this exact issue myself with chef+vagrant and found the following worked for me: sudo dpkg-reconfigure -plow grub-pc This allows you to reconfigure grub-pc and select the device (if any) you want grub installed on. Setting a device as default here should allow an upgrade that includes grub to not prompt for a device selection. At this ...


4

One thing to point out - if node['environment'] hasn't been set at all, your example would fail as it is. Here's the output I got: [Tue, 16 Oct 2012 02:40:31 +0000] INFO: Starting Chef Run for vagrant.int.housepub.org [Tue, 16 Oct 2012 02:40:31 +0000] INFO: Running start handlers [Tue, 16 Oct 2012 02:40:31 +0000] INFO: Start handlers complete. [Tue, 16 Oct ...


4

If you want to add individual hash elements to an array you can do it using the insertion operator << instead of the assignment operator = In cookbook A # Create the default attribute as an array default[:test]=[{:baz => 'A', :qux => 'B'}] In cookbook B # Using array insertion on an existing array default[:test] << {:baz => 'C', :...


4

I'm not aware of any other way than using the directory resource before the template resource: directory "#{node[:app][:deploy_to]}/#{node[:app][:name]}/shared/config/ owner node[:user][:username] group node[:user][:username] end


4

After some chat on the #chef IRC channel, here's what I ultimately needed to know. Most of it is actually peripheral info, rather than openssl passwd specific, but anyway... Chef users the standard adduser command (http://linux.die.net/man/8/adduser) for adding users. That command accepts the password already encrypted - Hence why you need to store an ...


4

Yes, you can use the UserData attribute of your AWS::EC2::Instance object. http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-instance.html#cfn-ec2-instance-userdata This attribute takes as input the base64-encoded version of your shell script. You can, however, provide the script inline with the help of a Cloudformation ...


3

Hmm. There should be chef output that indicates what's wrong. Looking at the cookbook, I see that it's trying to download maven 3 as: http://www.apache.org/dist/maven/binaries/apache-maven-3.0.3-bin.tar.gz (as specified in maven/attributes/default.rb, as the maven.3.url attribute). If you try to wget that URL, you'll get a 404. So, the cookbook is broken ...


3

The proper approach wrt chef/puppet et al is to package that software in your distro(')s native packaging format yourself and include it in your repositories and then to pull that package.


3

There's the cucumber-chef ruby gem and a recently released book Nelson-Smith et al - "Test-driven Infrastructure with Chef" that makes use of that gem - http://www.cucumber-chef.org/ Just remembered this from my github watchlist: https://github.com/gregretkowski/vmth/ The VMTH (Virtual Machine Test Harness) provides a mechanism to unit-test your ...


3

All users on the system are automatically detected by ohai when Chef runs, and available in the node['etc'] attribute space. Users are node['etc']['passwd']. You can iterate over this like a hash. You can exclude "system" or "precreated by packages" by comparing whether a user's numeric ID is over whatever is defined in your systems /etc/login.defs UID_MIN. ...


3

You should set the attributes you want on the node object(s) on the Chef Server. You can do this through a variety of methods. Add the attributes to the role you've applied to the nodes - this probably the best for systems that are all in a single role. Modify the node(s) directly, with knife node edit, or script it with knife exec. Set the attributes in ...


3

make your script name unique... bash "create_user_#{user}" do FWIW, I've used https://github.com/fnichol/chef-user several times which allows you to create/remove users based on attributes and databags.


3

There are some ways to keep execute from running several times on node: Using not_if, only_if statements. Using action :nothing and then notifying this execute resource to run from another resource. (only if you need to run it every time the first resource changes) Using creates [some/file] (Chef will run it, only if the file does not exist, equivalent to ...



Only top voted, non community-wiki answers of a minimum length are eligible