Essentially these are steps to keep an existing Server/Amazon Instance BUT to backup, then remove it's "meta data" from chef so that you can "reregister it"
The hostname of the server should match what it was registered with and what's stored in Opscode...
I've run into 401 (Unauthorized) errors before but the 409 error is strange.
It sounds like it's trying to re-register itself when it already exists.
Whenever I got the 401 errors I'd just delete the node, delete the client.pem, and re-register but that was always on new nodes.
All the important node info is stored in the node itself in the console:
- Copy the json node data out (edit the node and copy the attributes tree, there's a tree, node, and source/raw I think. You want the raw.)
- Make note of all the roles currently on a1
- Delete the node from the chef console and make sure the client.pem file is gone from a1
- (Might want to back up the webapps folder, the server.xml, and the /etc/default/tomcat6 at this point)
sudo chef-client -V
Essentially this should do nothing but register a new a1 node with the chef server
(since it has no roles or cookbooks it won't know to do anything, so it shouldn't remove anything that's there already. That's arguably one of the downsides of chef, it doesn't remove stuff automatically when you remove the role/cookbook).
- Paste the json data back in the reverse of how you got it out then save the node.
- Re-apply all the roles you wrote down from the node.
- Cross fingers and re-run the chef client
FQDN in /etc/chef/client.rb
Followup - required deleting the opscode client too!?
- Changing the client.rb to include name = domain.com
- Then running chef-client again worked!
knife list client
knife list node
knife node show atmosonline > atmosonline-knife-backup.txt
0 base_setup role
1 chef_client role
2 tomcat_server role
Attributes Tree json runit chpst_bin sv_bin service_dir sv_dir subversion tags apache dir binary icondir user log_dir
Source Tab (raw json)
{"runit":{"chpst_bin":"/usr/bin/chpst","sv_bin":"/usr/bin/sv","service_dir":"/etc/service","sv_dir":"/etc/sv"},"subversion":{},"tags":[],"apache":{"dir":"/etc/apache2","binary":"/usr/sbin/apache2","icondir":"/usr/share/apache2/icons","user":"www-data","log_dir":"/var/log/apache2"}}
mv /etc/chef/client.pem /etc/chef/client.pem.old
sudo chef-client -V
[Tue, 12 Apr 2011 17:48:16 +0000] INFO: Client key /etc/chef/client.pem is not present - registering
[Tue, 12 Apr 2011 17:48:16 +0000] INFO: Client key /etc/chef/client.pem is not present - registering
[Tue, 12 Apr 2011 17:48:16 +0000] WARN: HTTP Request Returned 409 Conflict: Client already exists.
[Tue, 12 Apr 2011 17:48:16 +0000] WARN: HTTP Request Returned 409 Conflict: Client already exists.
[Tue, 12 Apr 2011 17:48:17 +0000] WARN: HTTP Request Returned 404 Not Found: Cannot load node atmosonline
[Tue, 12 Apr 2011 17:48:17 +0000] WARN: HTTP Request Returned 404 Not Found: Cannot load node atmosonline
[Tue, 12 Apr 2011 17:48:20 +0000] INFO: Starting Chef Run (Version 0.9.14)
[Tue, 12 Apr 2011 17:48:20 +0000] INFO: Starting Chef Run (Version 0.9.14)
[Tue, 12 Apr 2011 17:48:20 +0000] WARN: Node atmosonline has an empty run list.
[Tue, 12 Apr 2011 17:48:20 +0000] WARN: Node atmosonline has an empty run list.
[Tue, 12 Apr 2011 17:48:21 +0000] INFO: Chef Run complete in 1.203183 seconds
[Tue, 12 Apr 2011 17:48:21 +0000] INFO: Chef Run complete in 1.203183 seconds
[Tue, 12 Apr 2011 17:48:21 +0000] INFO: cleaning the checksum cache
[Tue, 12 Apr 2011 17:48:21 +0000] INFO: cleaning the checksum cache
[Tue, 12 Apr 2011 17:48:21 +0000] INFO: Running report handlers
[Tue, 12 Apr 2011 17:48:21 +0000] INFO: Running report handlers
[Tue, 12 Apr 2011 17:48:21 +0000] INFO: Report handlers complete
[Tue, 12 Apr 2011 17:48:21 +0000] INFO: Report handlers complete
sudo chef-client -V
This time no 409 or 401 errors...
- OPSCODE -> NODES -> [NAME] EDIT -> SOURCE TAB -> PASTE -> *LOAD JSON FROM SOURCE
- DRAG AND DROP TO ADD BACK ALL OF THE ROLES THAT YOU COPY PASTED!
sudo chef-client -V
WORKS FINE...
INFO Add the chef::delete_validation recipe to the run list to remove the
/etc/chef/validation.pem
Note that you can define a Recipe that can be applied to a Role so that you can quickly setup Nodes with both services and configurations (via templates)
OPSCODE STATUS = shows the FQDN for controlling templates
~/chef-repo/cookbooks/COOKBOOKNAME/templates/host-FQDN/filename.erb
Cookbooks are how things are distributed and shared in Chef:
knife cookbook --help
knife cookbook list
Attributes in a Cookbook create settings on a node which can be accessed from a recipe.
templates are at servicename.app.properties.erb
/home/ubuntu/chef-repo/cookbooks/COOKBOOKNAME/definitions
servicename.rb