Skip to content

Commit

Permalink
add exercises for multiple nodes and search
Browse files Browse the repository at this point in the history
  • Loading branch information
jtimberman committed Feb 10, 2012
1 parent 4b2b240 commit 3b8a124
Showing 1 changed file with 92 additions and 0 deletions.
92 changes: 92 additions & 0 deletions guides/student-exercises/multiple-nodes-and-search.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,98 @@ Multiple Nodes And Search

## Objectives

* Add load balancer role with haproxy recipe
* Bootstrap a new node with load balancer role
* Use knife ssh to rerun chef client

## Acceptance Criteria

* Second instance bootstrapped with `knife bootstrap`.
* Second instance running haproxy load balancing webserver.
* Answer questions

## Haproxy Cookbook

Unless you did so in the previous exercise, download the `haproxy`
cookbook from the Chef Community Site.

We're going to use the `app_lb` recipe. Review the recipe, and the
attributes. Upload the cookbook to the Chef Server.

## Create Load Balancer Role

Create a role `load_balancer.rb` in the roles directory. Use
`recipe[haproxy::app_lb]` as the only item in the node's run list.

The `haproxy` cookbook uses the attribute `member_port` to specify
what port the web servers are listening to. Set this attribute in the
role to "80".

Upload the role to the Chef Server.

## Knife bootstrap Second Target

If Chef is not version 0.10.10 or higher, retrieve the chef-full
bootstrap template and put it in `.chef/bootstrap` in your Chef
Repository.

https://raw.github.com/opscode/chef/master/chef/lib/chef/knife/bootstrap/chef-full.erb

Your instructor will provide a second target system's IP address. Use
the `knife bootstrap` command to automatically set up the system with
the `base` and `load_balancer` roles with Chef.

Once complete, navigate to the public IP address of the load balancer
system in your web browser on port 80. Then navigate to the same IP on
port 22002.

Use the `chef-full` distro bootstrap with knife bootstrap to set up
the load balancer.

The node's run list should contain: `role[base]` and
`role[load_balancer]`. Base should be applied first.

## Use Knife Search

Use knife search to answer some of the questions below. Queries to use:

* "role:webserver"
* "role:base"
* "platform:ubuntu"
* "recipes:apt"
* "role:load_balancer"

## Knife SSH

Use `knife ssh` to run `sudo chef-client` on all nodes with the role
`base` applied directly to the run list.

Use `knife ssh` to report the `uptime` of all nodes with the recipe
`webserver` appearing anywhere in the run list (`recipes:webserver`).

## Questions

How does the `app_lb` recipe in the haproxy cookbook differ from the
default recipe?

How does the `haproxy::app_lb` recipe determine what nodes to search?
Can it be modified? If so, where would that be done?

How many nodes have HTTP traffic balanced by haproxy?

What other attributes does the haproxy cookbook have?

The haproxy cookbook has a `default` recipe. How does it differ from
the `app_lb` recipe?

How many nodes are running Ubuntu?

What is the run list of all the nodes? What option shows only the run
list from node results?

What is the node name of systems that are webservers?

Do any roles have a recipe from the apache2 cookbook in their run
list?

Do any nodes have a recipe from the apache2 cookbook?

0 comments on commit 3b8a124

Please sign in to comment.