54.246.93.253:9090
54.246.93.253/class.tar
Student Workshop user/password
ubuntu/opstrain_0150
i-ef9cb6a4: ec2-79-125-93-1.eu-west-1.compute.amazonaws.com (team 1)
i-5711261c: ec2-46-51-133-231.eu-west-1.compute.amazonaws.com
i-5511261e: ec2-46-137-15-127.eu-west-1.compute.amazonaws.com
i-6b112620: ec2-54-246-49-3.eu-west-1.compute.amazonaws.com
i-69112622: ec2-54-247-12-117.eu-west-1.compute.amazonaws.com
i-e39cb6a8: ec2-54-246-72-24.eu-west-1.compute.amazonaws.com (team 3)
i-6f112624: ec2-54-247-32-129.eu-west-1.compute.amazonaws.com
i-6d112626: ec2-54-246-60-43.eu-west-1.compute.amazonaws.com
i-63112628: ec2-79-125-42-93.eu-west-1.compute.amazonaws.com
i-6111262a: ec2-54-247-158-214.eu-west-1.compute.amazonaws.com
ec2-79-125-96-66.eu-west-1.compute.amazonaws.com
ec2-54-247-150-133.eu-west-1.compute.amazonaws.com (WS2)
Use the following for how to setup Chef client with Hosted Chef
http://wiki.opscode.com/display/chef/Fast+Start+Guide.
Cheat Sheet Notes....
sudo true && curl -L https://www.opscode.com/chef/install.sh | sudo bash
chef-client -v
cd ~ && git clone git://github.com/opscode/chef-repo.git
mkdir -p ~/chef-repo/.chef
copy /path/to/USERNAME.pem ~/chef-repo/.chef
copy /path/to/ORGANIZATION-validator.pem ~/chef-repo/.chef
copy /path/to/knife.rb ~/chef-repo/.chef
cd ~/chef-repo
knife client list
knife configure client ./client-config
ls -l client-config
sudo mkdir /etc/chef
sudo cp -r ~/chef-repo/client-config/* /etc/chef
sudo chef-client
Use the following for infromation about cookbooks
http://wiki.opscode.com/display/chef/Introduction+to+Cookbooks+and+More.
Cheat Sheet Notes....
cd ~/chef-repo/
knife cookbook create webserver
vi ~/chef-repo/cookbooks/webserver/metadata.rb
# Add as the last line...
depends "apache2"
# Add to the end of the file...
include_recipe "apache2"
template "/var/www/index.html" do
source "index.html.erb"
owner "root"
group "root"
mode "0644"
end
vi ~/chef-repo/cookbooks/webserver/templates/default/index.html.erb
# Add into the file...
<pre>
Platform: <%= node['platform'] %>
Platform Version: <%= node['platform_version'] %>
Default IP Address: <%= node['ipaddress'] %>
Fully Qualified Domain Name: <%= node['fqdn'] %>
Node's Run List: <%= node.run_list.to_s %>
</pre>
knife cookbook site vendor -d apache2
knife cookbook upload -a
# Get the Node name
knife node list
knife node run list add NODE 'recipe[webserver]'
sudo chef-client
curl localhost
Use the following for infromation about Roles
http://docs.opscode.com/essentials_roles.html.
Cheat Sheet Notes....
cd ~/chef-repo
knife node list
knife node run list remove NODE 'recipe[webserver]'
sudo chef-client
vi ~/chef-repo/roles/webserver.rb
# Add the following lines of code
name "webserver"
description "simple web app"
run_list(
"recipe[webserver]"
)
knife role from file ~/chef-repo/roles/webserver.rb
knife node run list add NODE 'role[webserver]'
sudo chef-client
Use the following for infromation about Roles
http://wiki.opscode.com/display/chef/Nodes.
Cheat Sheet Notes....
vi cookbooks/webserver/attributes/default.rb
# Add in the following line
default['webserver']['origin'] = "This is from the cookbooks attributes file"
knife cookbook upload -a
sudo chef-client
# Get the node name again...
knife node list
knife node show NOODE -a webserver -Fj
# Do some other node show commands...
knife node show NODE
knife node show NODE -Fj
# Add new definition to Role
vi ~/chef-repo/roles/webserver.rb
# Add to the end of the file...
default_attributes(
:webserver => {:origin => "This is from the role attributes file"}
)
knife role from file ~/chef-repo/roles/webserver.rb
sudo chef-client
knife node show NOODE -a webserver -Fj
More about Attributes...
http://wiki.opscode.com/display/chef/Attributes.
Use the following for more infromation about Cookbooks
http://docs.opscode.com/essentials_cookbooks.html.
Cheat Sheet Notes....
# Load up the apt, chef-client and fail2ban cookbooks
for i in apt chef-client fail2ban; do knife cookbook site vendor -d $i; done
# Create a Base role
vi ~/chef-repo/roles/base.rb
# Add the folliwng lines...
name "base"
description "Base role is applied to all systems"
run_list(
"recipe[apt]",
"recipe[fail2ban]",
"recipe[chef-client]"
)
knife cookbook upload -a
knife role from file ~/chef-repo/roles/base.rb
knife node run list add NODE 'role[base]'
knife node show NODE -r
sudo chef-client
knife cookbook site vendor -d haproxy
Use the following for more Advanced discussion about Multiple Nodes setups
http://wiki.opscode.com/display/chef/Build+a+LAMP+Stack.
Cheat Sheet Notes.... . vi ~/chef-repo/roles/load_balancer.rb
# Add the following lines...
name "load_balancer"
description "load balancer"
default_attributes(
:haproxy => {:member_port => 80}
)
run_list(
"recipe[haproxy::app_lb]"
)
knife role from file ~/chef-repo/roles/load_balancer.rb
knife cookbook upload -a
knife bootstrap <IP > -r 'role[base]','role[load_balancer]' --sudo -x ubuntu -Popstrain_0150
curl <IP>
http://wiki.opscode.com/display/chef/Build+A+Java+Web+Stack.
Cheat Sheet Notes....
###sudo apt-get install -y unzip git-core ruby1.8 rubygems libxslt-dev libxml2-dev
###sudo gem install chef knife-ec2 --no-ri --no-rdoc
###sudo update-alternatives --config ruby
git clone git://github.com/opscode/java-quick-start.git
cp -r ~/chef-repo/.chef ~/java-quick-start/.chef
vi ~/java-quick-start/.chef/knife.rb
# Add the Cloudstack credentials ...
###knife[:cloudstack_url] = "http://yourcloudstackserver.com:8080/client/api
###knife[:cloudstack_api_key] = "Your CloudStack API Key"
###knife[:cloudstack_secret_key] = "Your CloudStack Secret Key"
# For Amazon...
###knife[:aws_access_key_id] = "replace with the Amazon Access Key ID"
###knife[:aws_secret_access_key] = "replace with the Amazon Secret Access Key ID"
cd java-quick-start
for i in apt git application database dbapp haproxy; do knife cookbook site vendor -d $i; done
knife cookbook upload -a
for i in `ls *.rb`; do knife role from file $i ; done
# Need to create a users/dbappuser item
knife data bag create apps
cd ~/java-quick-start/
knife data bag from file apps dbapp.json
ec2-79-125-66-58.eu-west-1.compute.amazonaws.com
knife bootstrap ec2-54-247-144-241.eu-west-1.compute.amazonaws.com --sudo -x ubuntu -Popstrain_0150 \
-r 'role[base],role[dbapp_database_master],role[dbapp],recipe[dbapp::db_bootstrap],role[dbapp_load_balancer]'
knife ec2 server create -G default -I ami-7000f019 -f m1.small \
-S java-quick-start -i ~/.ssh/java-quick-start.pem -x ubuntu \
-r 'role[base],role[dbapp_database_master],role[dbapp],recipe[dbapp::db_bootstrap],role[dbapp_load_balancer]'