Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have a VM (hosted "in the cloud") that has been provisioned with chef using my organisation's own chef server.

I would like to replicate that VM locally (using a vagrant managed VM), in order to do some chef development.

I have been able to do what I want by creating a new node on chef server and manually copying the roles, recipes, attributes etc from the existing node.

It seems to me this would be a pretty common use case (i.e. to replicate a node/VM) and so there probably is a way to easily do it (without having to manually copy roles, recipes, attributes etc.) - but alas, I can't find one.

share|improve this question

2 Answers 2

What I do is setup a local VM (either via Vagrant or a simple VirtualBox VM) and then setup a complete Chef server installation there. Afterwards, I copy my normal knife.rb to an alternative knife.rb file (like knife.local.rb) where I change the Chef server's URL and upload all my data via

knife cookbook upload -a -c ~/.chef/knife.local.rb
knife data bag from file users users/* -c ~/.chef/knife.local.rb
etc etc...

Finally, when testing your cookbooks via Vagrant you can use the local Chef's address to do it! As a helper you can define an lknife function that can server as the knife tool for your local Chef. Just put in your user's .bashrc

function lknife { `which knife` "$@" -c "$HOME/.chef/knife.local.rb"; }
share|improve this answer
up vote 0 down vote accepted

knife edit can do it:

knife edit <existing node name>  # Change "name" attribute to something unique

This will create a new node with same run list and attributes (except for the name) as the existing node.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.