| 78 | Note that the {{{knife}}} command looks in ~/.chef and $(cwd)./chef for configuration files, so execute all {{{knife}}} commands from the {{{/local/chef-repo}}} directory or {{{knife}}} will be dull and not-happy. |
| 79 | |
| 80 | Push the local roles and recipes to the chef server. |
| 81 | {{{ |
| 82 | > cd /local/chef-repo |
| 83 | > knife cookbook upload hostsfile deter_node |
| 84 | Uploading hostsfile [2.4.4] |
| 85 | Uploading deter_node [0.1.1] |
| 86 | Uploaded 2 cookbooks. |
| 87 | > knife role from file roles/deter_node.rb |
| 88 | Updated Role deter_node! |
| 89 | > # Confirm things are OK. |
| 90 | > knife cookbook list |
| 91 | deter_node 0.1.1 |
| 92 | hostsfile 2.4.4 |
| 93 | > knife role list |
| 94 | deter_node |
| 95 | > |
| 96 | }}} |
| 97 | |
| 98 | We are now going to use {{{knife}}} to bootstrap Chef unto a client machine. The usual Chef assumes internet connectivity and asks you to download a script and pipe it to {{{sudo}}} on the client. We will not be doing that. |
| 99 | |
| 100 | {{{ |
| 101 | > cd /local/chef-repo |
| 102 | > mkdir .chef/bootstrap |
| 103 | > cp /share/chef/ubuntu12.04-deb.erb .chef/bootstrap |
| 104 | }}} |
| 105 | |
| 106 | The bootstrap usually grabs the package file from the internet. We give {{{chef}}} a custom bootstrap script that looks for it at {{{users:8523}}}. This means something on {{{users}}} must be listening on port 8523 and understand how to serve files via HTTPS. We use python for this. On {{{users}}}, cd to /share/chef and run {{{python -m SimpleHTTPServer 8523}}}. This starts a simple HTTP server on port 8523. If you want to run on your local server instead edit the file {{{/local/chef-repo/.chef/bootstrap/ubuntu12.04-deb.erb}}}, set the {{{SERVER}}} variable to the control net FQDN/ip address of your server and run the python simple server there. |
| 107 | |
| 108 | Now run the bootstrap command to install and configure chef on the client. {{{$NODE}}} is the control net name of the client node, like {{{pc33.isi.deterlab.net}}} and {{{$USER}}} if your sudo-able user name, like {{{glawler}}} or {{{faber}}}. |
| 109 | |
| 110 | {{{ |
| 111 | > knife bootstrap $NODE -x $USER --sudo --distro ubuntu12.04-deb |
| 112 | }}} |
| 113 | |
| 114 | Now kill the python SimpleHTTPServer process on users. |
| 115 | |
| 116 | Confirm the node has chef installed and configured by running this {{{knife}}} command on your workstation machine. It should show the client node. |
| 117 | |
| 118 | {{{ |
| 119 | > cd /local/chef-repo |
| 120 | > knife client list |
| 121 | chef-validator |
| 122 | chef-webui |
| 123 | pc33.isi.deterlab.net |
| 124 | > # show the node information: |
| 125 | > knife node show pc33.isi.deterlab.net |
| 126 | Node Name: pc33.isi.deterlab.net |
| 127 | Environment: _default |
| 128 | FQDN: pc33.isi.deterlab.net |
| 129 | IP: 192.168.1.33 |
| 130 | Run List: |
| 131 | Roles: |
| 132 | Recipes: |
| 133 | Platform: ubuntu 12.04 |
| 134 | Tags: |
| 135 | }}} |
| 136 | |
| 137 | Now we assign recipes or a role to the client node and tell it to configure itself. (Note this could've been done during the bootstrap via the {{{-r}}} argument. |
| 138 | |
| 139 | {{{ |
| 140 | workstation$ knife node run_list add pc33.isi.deterlab.net 'role[deter_node]' |
| 141 | pc33.isi.deterlab.net: |
| 142 | run_list: role[deter_node] |
| 143 | }}} |