Skip to content
This repository
Browse code

Rename fabfile.py to littlechef.py

Check that nodes/ exists
  • Loading branch information...
commit b0880d11d959da6995d7ca996add2a2fa5a9e5d6 1 parent 94bada9
Miquel Torres authored
2  LICENSE
... ... @@ -1,4 +1,4 @@
1   - Apache License
  1 + Apache License
2 2 Version 2.0, January 2004
3 3 http://www.apache.org/licenses/
4 4
40 README.textile
Source Rendered
@@ -17,18 +17,29 @@ in the @littlechef@ directory there is:
17 17
18 18 h3. How it all works
19 19
20   -Whenever you apply a recipe to a node, your cookbook dir is gzipped and uploaded to that node. A node.json file gets created on the fly and uploaded, and Chef Solo gets executed at the remote node, using node.json as the node configuration and the pre-installed solo.rb for Chef Solo configuration. Cookbooks and roles are configured to be found at (@/tmp/chef-solo/@).
  20 +Whenever you apply a recipe to a node, your cookbook dir is gzipped and uploaded to that node. A node.json file gets created on the fly and uploaded, and Chef Solo gets executed at the remote node, using node.json as the node configuration and the pre-installed solo.rb for Chef Solo configuration. Cookbooks and roles are configured to be found at @/tmp/chef-solo/@.
21 21
22   -The result is that you can play as often with your recipes and nodes as you want, without having to worry about repositories, central servers nor anything else. Once you are satisfied with a new feature in a cookbook, you can commit the @littlechef/cookbook/ directory@ to your repository. LittleChef brings back sanity to cookbook development.
  22 +The result is that you can play as often with your recipes and nodes as you want, without having to worry about repositories, central servers nor anything else. Once you are satisfied with a new feature in a cookbook, you can commit the @littlechef/cookbook/@ directory to your repository. LittleChef brings back sanity to cookbook development.
23 23
24 24 h2. Requirements
25 25
26 26 * Python 2.6+
27   -* Fabric 0.9.2 (python-fabric package in Ubuntu and Debian based distros)
  27 +* Fabric 0.9.2
  28 +
  29 +All needed packages should get installed by typing
  30 +@sudo apt-get install python-fabric@ for Debian and Ubuntu
  31 +or
  32 +@yum install fabric@ for RHEL and CentOS
28 33
29 34 h2. Installation
30 35
31   -There is none. You just need to install the required packages and download and uncompress LittleChef. To start cooking change to the @littlechef@ dir and always issue commands from there, calling @./cook@ (you can create an alias so that you can write 'cook' without the './')
  36 +There is none. You just need to install the required packages and download and uncompress LittleChef.
  37 +
  38 +To start cooking change to the @littlechef@ dir and always issue commands from there, calling @./cook@
  39 +
  40 +For convenience, you can copy the file @cook@ to your PATH. For example:
  41 +@sudo cp cook /user/bin/@
  42 +You will then be able to type @cook@ instead of @./cook@.
32 43
33 44 h2. Usage
34 45
@@ -39,9 +50,9 @@ Careful what you do with your nodes!:
39 50 bq. A certain famous Chef: What do I always say? Anyone can cook.
40 51 Little Chef: Yeah. Anyone can, that doesn't mean that anyone should.
41 52
42   -h3. Preparing and cooking
  53 +h3. Setup
43 54
44   -To be able to issue commands to remote nodes, you need to enter a user and a password with sudo rights. For that, create a file named @auth.py@ and enter, ini format style:
  55 +To be able to issue commands to remote nodes, you need to enter a user and a password with sudo rights. For that, create a file named @auth.cfg@ and enter, in ini format style:
45 56
46 57 bc. [userinfo]
47 58 user = yoursudouser
@@ -50,7 +61,7 @@ password = yourpassword
50 61 h3. Deploy
51 62
52 63 There is a command that allows you to deploy chef-client/-solo to a node using the packages from the "Opscode repository":http://wiki.opscode.com/display/chef/Installation#Installation-InstallingChefClientandChefSolo:
53   -@fab node:MYNODE deploy_chef:MYDISTRO@
  64 +@./cook node:MYNODE deploy_chef:MYDISTRO@
54 65
55 66 MYDISTRO can have one of the following values for debian based distributions:
56 67 'lucid', 'karmic', 'jaunty', 'hardy', 'sid', 'squeeze', 'lenny'
@@ -63,29 +74,30 @@ Also, the CentOS and RHEL installation method has not been tested. Feedback is w
63 74
64 75 h3. Cook
65 76
  77 +Note: Allways cook inside your local @littlechef/@ directory.
  78 +
66 79 * @./cook -l@: Show a list of all available commands.
67 80 * @./cook node:MYNODE recipe:MYRECIPE@: Cook a recipe on a particular node by giving its hostname or IP.
68 81 Note that the first time this is run for a node, a configuration file will be created at @nodes/hostname.json@. You can then edit this file to override recipe attributes for example. Further runs of this command will not overwrite this configuration file.
69 82 You can force the saving of the run with @./cook node:MYNODE recipe:MYRECIPE,save=True@.
70 83 * @./cook node:MYNODE role:MYROLE@: The same as above but role-based
71   -* @./cook node:MYNODE configure@: Configures node as specified in an existing config file
72   -* @./cook configure@: Configures all nodes present in @littlechef/nodes/@
  84 +* @./cook configure@: It will apply all roles, recipes and attributes defined in @nodes/MYNODE.json@ to ALL nodes present in @littlechef/nodes/@.
73 85 * @./cook node:MYNODE configure@: Configures a particular pre-configured node
74 86 * @./cook debug configure@: You can start all your commands with @./cook debug@ to see all Chef Solo debbuging information
75 87
76 88 h3. Consulting the inventory
77 89
78   -* @fab list_nodes@: Lists all nodes showing its associated recipes, roles and attributes
79   -* @fab list_nodes_with_recipe:MYRECIPE@: The same as above but it only lists nodes which have associated the recipe @MYRECIPE@
80   -* @fab list_nodes_with_role:MYROLE@: The same as above but it only lists nodes which have associated the role @MYROLE@
  90 +* @./cook list_nodes@: Lists all nodes showing its associated recipes, roles and attributes
  91 +* @./cook list_nodes_with_recipe:MYRECIPE@: The same as above but it only lists nodes which have associated the recipe @MYRECIPE@
  92 +* @./cook list_nodes_with_role:MYROLE@: The same as above but it only lists nodes which have associated the role @MYROLE@
81 93
82 94 h2. Getting started
83 95
84 96 There are some sample cookbooks and a sample role to get you started.
85 97 try:
86   -@fab node:MYNODE1 recipe:nginx@
  98 +@./cook node:MYNODE1 recipe:nginx@
87 99 and
88   -@fab node:MYNODE2 recipe:haproxy@
  100 +@./cook node:MYNODE2 recipe:haproxy@
89 101
90 102 The haproxy is a modified opscode recipe so that it accepts an array of load balanced servers. You can edit the new configuration file at @nodes/MYNODE2.json@ and add some attributes. Make it look like this (ignore the littlechef custom fields):
91 103
2  cook
... ... @@ -1,2 +1,2 @@
1 1 #!/bin/bash
2   -fab $@
  2 +fab -f littlechef.py $@
3  fabfile.py → littlechef.py
@@ -37,8 +37,9 @@ def _readconfig():
37 37 abort('You need to define a valid user in auth.cfg')
38 38 env.password = config.get('userinfo', 'password')
39 39 except ConfigParser.NoSectionError:
40   - abort('No section "userinfo" found in auth.cfg. Refer to the README for help')
  40 + abort('You need to define user and password in the "userinfo" section of auth.cfg. Refer to the README for help')
41 41 env.loglevel = "info"
  42 + if not os.path.exists('nodes'): os.mkdir('nodes')
42 43
43 44 _readconfig()
44 45

0 comments on commit b0880d1

Please sign in to comment.
Something went wrong with that request. Please try again.