Changes between Version 11 and Version 12 of ChefonDETER


Ignore:
Timestamp:
Jul 15, 2014 1:34:34 PM (10 years ago)
Author:
Geoff Lawler
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ChefonDETER

    v11 v12  
    77The workflow for a running system is recipes, roles, and chef code is written on a workstation and added to a chef repository. The person on the workstation then pushes updates to the chef server. The client then contacts the chef server for updates, gets the updates, and applies them locally. {{{Knife}}}, on a workstation, can also install Chef-client (and other packages) directly on a client. If this is done the flow becomes: 1) workstation pushes update to the server, 2) the workstation installs Chef on a client and gives it an initial role or list of recipes, 3) the newly installed {{{chef-client}}} then contacts the chef server and downloads the recipes and executes them, configuring the client node.
    88
    9 Note: the recipes here use a mysql library to talk directly to the testbed database. On the current DETER testbed though, the database is setup to only allow local access from boss. The TMCD/TMCC library is used to bridge the gap between test nodes and the database on boss. The recipes can be rewritten to use the TMCD interface but this was an exercise in trying to cut out Emulab code, a decision was made to talk directly to the database using standard database APIs. In short, the cookbook (and recipes) here cannot be run on DETER unless the database on boss is reconfigured to allow external access. Instructions are given for that below though. If you want to run the recipes, spin up an Emulab in Emulab experiment or access a local, non-public DETER/Emulab instance and modify the database configuration. 
     9Note: the recipes here use a mysql library to talk directly to the testbed database. On the current DETER testbed though, the database is setup to only allow local access from boss. The TMCD/TMCC library is used to bridge the gap between test nodes and the database on boss on DETER. The recipes can be rewritten to use the TMCD interface but this was an exercise in trying to cut out Emulab code, a decision was made to talk directly to the database using standard database APIs. In short, the cookbook (and recipes) here cannot be run on DETER unless the database on boss is reconfigured to allow external access. Instructions are given for that below though. If you want to run the recipes, spin up an Emulab in Emulab experiment or access a local, non-public DETER/Emulab instance and modify the database configuration. 
    1010
    1111Swap in an experiment with at least three Ubuntu 12.04 nodes, one {{{server}}}, one {{{workstation}}}, and one {{{client}}}.
     
    1515
    1616{{{
    17 > ssh server
    18 > # if you don't want to hammer NFS, copy deb to /tmp first.
    19 > sudo dpkg -i /share/chef/chef-server_11.0.12-1.ubuntu.12.04_amd64.deb
    20 > sudo chef-server-ctl reconfigure
    21 > sudo chef-server-ctl test
     17users$ ssh server
     18server$ # if you don't want to hammer NFS, copy deb to /tmp first.
     19server$ sudo dpkg -i /share/chef/chef-server_11.0.12-1.ubuntu.12.04_amd64.deb
     20server$ sudo chef-server-ctl reconfigure
     21server$ sudo chef-server-ctl test
    2222}}}
    2323
     
    2828Install Chef software:
    2929{{{
    30 > ssh workstation
    31 > sudo dpkg -i /share/chef/chef_11.10.4-1.ubuntu.12.04_amd64.deb
    32 > chef-client -v                # test - should show version.
     30users$ ssh workstation
     31workstation$ sudo dpkg -i /share/chef/chef_11.10.4-1.ubuntu.12.04_amd64.deb
     32workstation$ chef-client -v                # test - should show version.
    3333}}}
    3434
    3535Install git and the chef-repo:
    3636{{{
    37 > sudo apt-get install -y git   # chef uses git.
    38 > sudo chmod g+w /local
    39 > cd /local
    40 > git clone /share/chef/chef-repo
    41 > cd chef-repo
     37workstation$ sudo apt-get install -y git   # chef uses git.
     38workstation$ sudo chmod g+w /local
     39workstation$ cd /local
     40workstation$ git clone /share/chef/chef-repo
     41workstation$ cd chef-repo
    4242}}}
    4343
    4444Take a look in {{{/local/chef-repo/cookbooks/deter_node/recipes}}} for the "deter_node" recipes. There is also a simple "deter_node" role in {{{/local/chef-repo/roles/deter_node.rb}}} that has a {{{run_list}}} that tells the node to execute the recipes in the correct order. 
    4545
    46 Now configure the workstation user and set up keys. Note that there *is* a web interface for this and that is the standard interface to use for this. Since it assumes you're running the browser locally though, you need to setup an ssh tunnel and a web proxy like Foxy-Proxy to access it. For this script though (and because we prefer it as it's scriptable) we stick to the command line. To do this though, we need to copy private keys. The procedure for using the web API copies public keys from a web page.
    47 
    48 {{{
    49 > mkdir .chef
    50 > # copy keys!
    51 > ssh server sudo cat /etc/chef-server/admin.pem > .chef/admin.pem
    52 > ssh server sudo cat /etc/chef-server/chef-validator.pem  > .chef/chef-validator.pem
    53 > # use knife to configure the account/workstation
    54 > knife configure --initial
     46Now configure the workstation user and set up keys. Note that there *is* a web interface for this and that is the standard interface to use for this. Since it assumes you're running the browser locally though, you need to setup an ssh tunnel and a web proxy like Foxy-Proxy to access it. For this script though (and because we prefer it as it's scriptable) we stick to the command line. To do this, we need to copy private keys. (The procedure for using the web API copies public keys from a web page so is the preferred method.)
     47
     48{{{
     49workstation$ cd /local/chef-repo
     50workstation$ mkdir .chef
     51workstation$ # copy keys!
     52workstation$ ssh server sudo cat /etc/chef-server/admin.pem > .chef/admin.pem
     53workstation$ ssh server sudo cat /etc/chef-server/chef-validator.pem  > .chef/chef-validator.pem
     54workstation$ # use knife to configure the account/workstation
     55workstation$ knife configure --initial
    5556}}}
    5657
    5758Answer the questions, substituting in your uid and server's control-net FQDN. A sample run is shown here:
    5859{{{
    59 > knife configure --initial                                           
     60workstation$ knife configure --initial                                           
    6061WARNING: No knife configuration file found                                                                           
    6162Where should I put the config file? [/users/glawler/.chef/knife.rb] /local/chef-repo/.chef/knife.rb                   
     
    7172Created user[glawler]                                                                                                 
    7273Configuration file written to /local/chef-repo/.chef/knife.rb                                                         
    73 > # Validate server connection and user.
    74 > knife user list
     74workstation$ # Validate server connection and user.
     75workstation$ knife user list
    7576admin
    7677glawler
    77 >
     78workstation$
    7879}}}
    7980
     
    8283Push the local roles and recipes to the chef server.
    8384{{{
    84 > cd /local/chef-repo
    85 > knife cookbook upload hostsfile deter_node
     85workstation$ cd /local/chef-repo
     86workstation$ knife cookbook upload hostsfile deter_node
    8687Uploading hostsfile    [2.4.4]                                                               
    8788Uploading deter_node   [0.1.1]                                                               
    8889Uploaded 2 cookbooks.                                                                       
    89 > knife role from file roles/deter_node.rb
     90workstation$ knife role from file roles/deter_node.rb
    9091Updated Role deter_node!
    91 > # Confirm things are OK.
    92 > knife cookbook list
     92workstation$ # Confirm things are OK.
     93workstation$ knife cookbook list
    9394deter_node   0.1.1
    9495hostsfile    2.4.4
    95 > knife role list
     96workstation$ knife role list
    9697deter_node
    97 >
     98workstation$
    9899}}}
    99100