Browse files

Merge branch 'centos-exercises'

  • Loading branch information...
2 parents 5f63b0b + f8e93fd commit 5294e8f9b7e0bcce983d60cb66afbf4ba180d686 @jtimberman jtimberman committed Apr 26, 2012
@@ -14,12 +14,27 @@ Anatomy of a Chef Run
## Prepare Remote Target
Your instructor will provide an IP address of an Ubuntu
system. Connect to the system with the following credentials:
* Username: ubuntu
* Password: opstrain_0150
+You should have the Virtual Machine created in VMware (Player,
+Workstation, Fusion) on your workstation. The login credentials are:
+* Username: root
+* Password: opscodechef
+Log in and run `/sbin/ifconfig` or `/sbin/ip addr` to get the system's
+IP address.
You will need to install Chef on the system. Use the Full Stack
@@ -40,7 +55,8 @@ location per platform:
At a minimum, the configuration should include the Chef Server URI
(`chef_server_url`), and the name of the validation API client
(`validation_client_name`). Refer to your Knife configuration file for
+values of these settings. Also, set `node_name` to
## Use Validation Key
@@ -54,6 +70,9 @@ Run `chef-client` on the local system with debug logging, and send the
output to a file. Use the output file, along with the command-line
tools to answer the following questions.
+**Ubuntu**: You'll need to either su to root or use sudo to execute
## Questions
What is the name of the node and client created on the Chef Server?
@@ -9,22 +9,33 @@ Cookbooks, Recipes, and Resources
## Acceptance Criteria
-* Directory `/var/www` is created and owned by www-data user.
+* Directory `/var/www` is created and owned by www-data (Ubuntu) or
+ apache (CentOS) user.
* File `/var/www/index.html` is rendered from a template.
* Answer the questions.
+## Webserver User
+If your target system is Ubuntu, the owner is `www-data`.
+If your target system is CentOS, the owner is `apache`.
## Create webserver Cookbook
Create a cookbok named `webserver` in the cookbooks directory. It
should have a `default.rb` recipe that configures two resources:
* The `/var/www` directory, which should be owned by the www-data
- user.
+ or apache user.
* An `index.html` file in `/var/www` rendered from a template, also
- owned by www-data.
+ owned by www-data or apache.
The source template should contain information about the
-node from attributes. Minimum:
+node from its attributes. Minimum:
* Platform and Platform version (`node['platform']`,
@@ -33,6 +44,9 @@ node from attributes. Minimum:
* EC2 public IP address (`node['ec2']['public_ipv4']`)
* The node's run list (`node.run_list.to_s`)
+The file we're editing is HTML, but don't worry about HTML tags and
+formatting, you may wrap the text in `<pre>` / `</pre>`.
Create the `metadata.rb` file with the cookbook's initial version. Use
any version number you like using the form X.Y.Z, e.g., "1.0.0" or
@@ -42,10 +56,19 @@ Upload the cookbook to the Chef Server.
__Note__: We are not installing Apache HTTPD as part of this
exercise. The `index.html` file can be viewed as plain text.
+## (Optional) Use a conditional for the user
+The owner of the directory and template can be set using a conditional
+based on the value of the `node['platform']` attribute so that it is
+`www-data` when the node's platform is `ubuntu` or `apache` when the
+node's platform is `centos`. As an optional exercise, you may do this
+in the recipe.
## Apply webserver Cookbook to a node
Add the `webserver` cookbook's default recipe to your existing node
-from the previous exercise using Knife.
+from the previous exercise using Knife. It should be the only node in
+`knife node list`.
Log into the node and run `chef-client`. Turn debug logging on to see
more information about the Chef run.
@@ -43,6 +43,9 @@ Subversion or any other version control system you wish.
## Create Opscode Hosted Chef Account
+_This is only required if you're not using an internal Private Chef
+server for the exercises._
Create a user account for Opscode Hosted Chef, then sign in and create
an organization. Remember that the organization short name must be
ASCII alpha-numeric, no spaces (dashes and underscores **are** allowed).
@@ -58,6 +61,10 @@ validation key file to the same directory.
Verify connectivity to the Chef Server for your user with knife on the
local workstation.
+ > knife client list
+Should list at least the validator client name for the organization.
## Questions
Where are Chef and Ruby binaries installed on the system?
@@ -3,13 +3,13 @@ More Cookbooks
## Objectives
-* Apply apt, chef-client, and fail2ban recipes via a base role
+* Apply apt or yum, chef-client, and fail2ban recipes via a base role
* Include the apache2 recipe in the webserver recipe
* Download and examine the haproxy cookbook
## Acceptance Criteria
-* "base" role is created with the apt, chef-client and fail2ban
+* "base" role is created with the apt or yum, chef-client and fail2ban
* "base" role is applied to the remote target system.
* Answer the questions
@@ -19,23 +19,40 @@ More Cookbooks
Download the following cookbooks to the local repository and extract
them in the `cookbooks` directory.
-* apt
* chef-client
* fail2ban
* apache2
+If your target system is Ubuntu, also download and extract the `apt`
+If your target system is CentOS, also download and extract the `yum`
With a single knife command, upload all four cookbooks.
## Create base role
+If your target system is Ubuntu, use `recipe[apt]`.
+If your target system is CentOS, use `recipe[yum::epel]`.
+**Role Run List**
In the roles directory, create a `base.rb` for the base role. It
should have a run list containing the `apt`, `fail2ban` and
`chef-client` recipes.
- recipe[apt],
+ recipe[apt] OR recipe[yum::epel]
+Be sure to use only apt OR yum:epel.
## Add apache2 to webserver cookbook
Use `include_recipe` in the `webserver` cookbook's default recipe to
@@ -35,14 +35,17 @@ 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
+bootstrap template and save it as `.chef/bootstrap/chef-full.erb` in
+your Chef Repository.
-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.
+Your instructor will provide a second target system's IP address or
+you will use a second Virtual Machine. Use the `knife bootstrap`
+command to automatically set up the system with the `base` and
+`load_balancer` roles with Chef. When running the `knife bootstrap`
+command, specify the new system's node name with `-N NODENAME`, e.g.
+`-N load-balancer.localdomain`.
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

0 comments on commit 5294e8f

Please sign in to comment.