Automated OpenStack Installs you say? Build my own Private Cloud you say? DevOps, Hybrid, and the intercloud? Ok, so, now that we’ve scored buzzword bingo, what am I talking about?
Edits in Mace-Windu
After you get Chef going…
- Part 2 – Installing and configuring Razor with Chef: http://openstack.prov12n.com/chef-razor-openstack-part-2/
- Part 3 – Bringing it all together, installing OpenStack with Chef & Razor: http://openstack.prov12n.com/chef-razor-openstack-part-3/
As part of the upcoming release for the OpenStack Cookbook, I am revamping the JuJu/MaaS chapter to make it a bit less Ubuntu specific. Not that there is anything wrong with those tools, we just wanted to take a more generic approach to helping you build OpenStack at scale. This series of posts will walk you through building a Chef 11 server and pulling in the Razor & Rackspace OpenStack cookbooks. Use Chef Server to deploy PuppetLabs Razor, download an image, create a broker in Razor for Chef, and the other varied bits that will be needed. Finally, we will create a bunch of nodes and use Razor to provision an OS and hand off to Chef for making the OpenStack magic.
Sound like a lot? That’s why we’re breaking it up into a few parts. This one covers installing Chef Server and procuring our cookbooks. Note on Chef v Puppet – My intention is not to pick one for you, that said, we had to pick one for writing the book. If you find puppet works better, the high level process flow should work about the same.
Installing Chef Server
Chef Server is the glue which will hold the rest of our environment together. It contains the instructions (cookbooks and roles, etc) that describe how our environment will be built.
Getting Started
To begin, we assume a basic Ubuntu 12.04 VM with 2GB ram, 1 vCPU, and 20GB disk. Log into this VM and run the following commands:
wget -O chef-server-11.deb https://opscode-omnitruck-release.s3.amazonaws.com/ubuntu/12.04/x86_64/chef-server_11.0.6-1.ubuntu.12.04_amd64.deb
sudo dpkg -i chef-server-11.deb
sudo chef-server-ctl reconfigure
sudo chef-server-ctl test
mkdir ~/.chef
cp /etc/chef-server/admin.pem ~/.chef
cp /etc/chef-server/chef-validator.pem ~/.chef
# Install chef client
curl -L https://www.opscode.com/chef/install.sh | sudo bash
# Make knife.rb
sudo cat > ~/.chef/knife.rb <<EOF
log_level :info
log_location STDOUT
node_name ‘admin’
client_key ‘~/.chef/admin.pem’
validation_client_name ‘chef-validator’
validation_key ‘~/.chef/chef-validator.pem’
chef_server_url ‘https://chef.book’
cookbook_path ‘/root/cookbooks/’
syntax_check_cache_path ‘~/.chef/syntax_check_cache’
EOF
# Pull down the Razor & Rackspace OpenStack cookbooks
sudo git clone git://github.com/opscode/chef-repo.git /root/cookbooks
sudo git clone –recursive git://github.com/rcbops/chef-cookbooks.git /root/alamo
sudo knife cookbook site install razor
sudo knife cookbook site install dhcp
sudo knife data bag create dhcp_networks
mkdir -p /root/databags/dhcp_networks
sudo cat > /root/databags/dhcp_networks/razor_dhcp.json <<EOF
{
“id”: “172-16-0-0_24”,
“routers”: [ “172.16.0.2” ],
“address”: “172.16.0.0”,
“netmask”: “255.255.255.0”,
“broadcast”: “172.16.0.255”,
“range”: “172.16.0.50 172.16.0.59”,
“options”: [ “next-server 172.16.0.101” ]
}
EOF
sudo knife data bag from file dhcp_networks /root/databags/dhcp_networks/razor_dhcp.json
sudo knife cookbook upload -o /root/alamo/cookbooks –all
RAZOR_IP=”172.16.0.101″
sudo sed -i “s/node[‘ipaddress’]/$RAZOR_IP/g” /root/cookbooks/razor/attributes/default.rb
sudo knife cookbook upload -o /root/cookbooks –all
sudo knife role from file /root/alamo/roles/*.rb
How it Works
We first install and configure chef server:
wget -O chef-server-11.deb https://opscode-omnitruck-release.s3.amazonaws.com/ubuntu/12.04/x86_64/chef-server_11.0.6-1.ubuntu.12.04_amd64.deb
sudo dpkg -i chef-server-11.deb
sudo chef-server-ctl reconfigure
sudo chef-server-ctl test
Then we install chef-client, knife, and preform some configuration:
curl -L https://www.opscode.com/chef/install.sh | sudo bash
sudo cat > ~/.chef/knife.rb <<EOF
log_level :info
log_location STDOUT
node_name ‘admin’
client_key ‘~/.chef/admin.pem’
validation_client_name ‘chef-validator’
validation_key ‘~/.chef/chef-validator.pem’
chef_server_url ‘https://chef.book’
cookbook_path ‘/root/cookbooks/’
syntax_check_cache_path ‘~/.chef/syntax_check_cache’
EOF
Finally, we gather our cookbooks and roles for the various services our environment will need:
# Pull down the Razor & Rackspace OpenStack cookbooks
sudo git clone git://github.com/opscode/chef-repo.git /root/cookbooks
sudo git clone –recursive git://github.com/rcbops/chef-cookbooks.git /root/alamo
sudo knife cookbook site install razor
sudo knife cookbook site install dhcp
sudo knife data bag create dhcp_networks
mkdir -p /root/databags/dhcp_networks
sudo cat > /root/databags/dhcp_networks/razor_dhcp.json <<EOF
{
“id”: “172-16-0-0_24”,
“routers”: [ “172.16.0.2” ],
“address”: “172.16.0.0”,
“netmask”: “255.255.255.0”,
“broadcast”: “172.16.0.255”,
“range”: “172.16.0.50 172.16.0.59”,
“options”: [ “next-server 172.16.0.101” ]
}
EOF
sudo knife data bag from file dhcp_networks /root/databags/dhcp_networks/razor_dhcp.json
sudo knife cookbook upload -o /root/alamo/cookbooks –all
RAZOR_IP=”172.16.0.101″
sudo sed -i “s/node[‘ipaddress’]/$RAZOR_IP/g” /root/cookbooks/razor/attributes/default.rb
sudo knife cookbook upload -o /root/cookbooks –all
sudo knife role from file /root/alamo/roles/*.rb
Summary
What we’ve covered here lays the foundation for building a DevOps OpenStack Cloud Factory. We’ve installed the Chef Server and uploaded the cookbooks that will be needed to build the remainder of the environment. If you have any questions, complaints, etc, drop a line in the comments or follow me on twitter here.
Resources
- http://www.opscode.com/blog/2013/03/11/chef-11-server-up-and-running/
- https://github.com/rcbops/chef-cookbooks
Edits
Added a few bits to configure DHCP. You’ll not want to use this if you have a DHCP server in your environment already. However, as we’re doing this entirely nested in VMs, this is the route to go.
5 thoughts on “Chef, Razor, OpenStack – Part 1”