Continued from

CHEF Cookbook Tutorial on AWS EC2 Ubuntu

 

cd cookbooks/phpapp

 

Now we’d need write our cookbook to install and configure Apache, MySQL and PHP.
Welcome to the Opscode Community cookbook site.
Here you’ll find lots of well crafted, tested and battle hardened cookbooks that will do most of the work for you. Think of them as libraries you will use inside your code. We’ll start with the apache2 cookbook. There’s no need to manually download it from the community site, knife has this functionality built in. We’ll also install the apt cookbook. This will help us ensure chef-solo does an apt-get update before we install any packages.
 
cd ..
knife cookbook site download apache2
tar zxf apache2*
rm apache2*.tar.gz
knife cookbook site download apt
tar zxf apt*
rm apt*.tar.gz
knife cookbook site download iptables
tar zxf iptables*
rm iptables*.tar.gz
knife cookbook site download logrotate
tar zxf logrotate*
rm logrotate*.tar.gz
knife cookbook site download pacman
tar zxf pacman*
rm pacman*.tar.gz
knife cookbook site download compat_resource
tar xvf compat_resource-12.10.7.tar.gz
rm compat_resource-12.10.7.tar.gz
cd phpapp
vi metadata.rb # and addthe line
depends “apache2”
vi recipes/default.rb # add the lines
include_recipe “apache2”
apache_site “default” do
enable true
end
cd ..
create solo.rb
vi solo.rb
file_cache_path “/root/chef-solo”
cookbook_path “/root/chef-repo/cookbooks”
create web.json
vi web.json
{
“run_list”: [ “recipe[apt]”, “recipe[phpapp]” ]
}
chef-solo -c solo.rb -j web.json
DONE