Thursday, June 20, 2013

Playing with Chef

Recently I got a bit overwhelmed with all the servers I maintain and have to update and so decided to ease my life and start using an automation system. Don't really care that much about my real servers. But having quite a lot of dedicated virtual machines, I guess it was time to simplify this process.

Bootstrapping a system
knife bootstrap systemname-x username -P password --sudo
Installing a cookbook from the central repository
knife cookbook site install name-of-cookbook
Uploading a cookbook to the server
knife cookbook upload name-of-cookbook
Adding a recipe to a system
 knife node run_list add HOSTNAME 'recipe[recipe]'

Updating all systems
knife ssh "*:*" "sudo chef-client" -x username -P password
Updating/Adding a data bag
knife data bag from file BAG_NAME ITEM.json
Changing the environment for nodes
knife exec -E 'nodes.transform("chef_environment:dev") { |n| n.chef_environment("production") }'
Adding a role to all nodes in a certain environment
knife exec -E 'nodes.transform("chef_environment:Fiehnlab") {|n| puts n.run_list << "role[user-management]"; n.save }'
Overriding the runlist for a single run
chef-client -o  recipe["rocks-cluster-6.1::computenode"]

Just a small overview for me to remember some commands.

No comments:

Post a Comment