Chef Part 4

Last post I mentioned that one of our nodes is using a recipe we wrote to install Webmin. We have two nodes running, so we decided to run something different on the second one. We wrote an Apache cookbook to install and configure it. Below is our recipe:


#
# Cookbook Name:: apache2
# Recipe:: default
#
apt_update 'Update the apt cache daily' do
frequency 86_400
action :periodic
end

package 'apache2'

service 'apache2' do
supports :status => true
action [:enable, :start]
end

file '/var/www/html/index.html' do
content '<html>
<body>
<h1>hello world</h1>
</body>
</html>'
end

It’s pretty simple just like the webmin cookbook. Thankfully I didn’t have to use any bash on this one.

The apt_update package just runs

apt-get update

.

package’apache2′  is basically the same as running

apt-get install apache2

.

The service resources simply enables and starts the apache 2 service. The file resource changes the content of index.html to be the html that I posted above.

It’s neat that Chef does all of this stuff automatically. It makes it easy to setup an apache web server really quickly.

Posted in Senior project

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

Categories
%d bloggers like this: