Skip to content

Commit

Permalink
cook-149, add kickstart cookbook
Browse files Browse the repository at this point in the history
  • Loading branch information
jtimberman committed Jul 3, 2009
0 parents commit d8b536a
Show file tree
Hide file tree
Showing 7 changed files with 408 additions and 0 deletions.
51 changes: 51 additions & 0 deletions README.rdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
= DESCRIPTION:

Creates an apache vhost and serves a very basic kickstart file.

= REQUIREMENTS:

Red Hat Enterprise Linux, CentOS, or other platforms that support Kickstart :-).

Opscode/cookbooks:

* apache2

= ATTRIBUTES:

* kickstart[:rootpw] - set the root password. Use an encrypted string[1].

[1] a Ruby way to encrypt:
http://www.opensourcery.co.za/2009/05/01/quick-nix-shadow-passwords-with-ruby/

= USAGE:

You'll almost certainly want to edit ks.cfg.erb to suit your environment. As is, the provided template is used as a minimal fast install for creating virtual machines to run CentOS 5. Of particular note, the following should definitely be changed:

* url - mirrors.kernel.org is usually fast for me, but maybe not for you.
* network - change the hostname.
* rootpw - this is an attribute, so you can change it by modifying the server. Use the encrypted password!

Storage / disks should probably be customized, as well as firewall rules, SELinux policy, and the package list.

The %post section will install Chef via Matthew Kent's RPMs, per the Chef Wiki instructions.

To use the recipe on a system that will be the kickstart server,

include_recipe "kickstart::server"

= LICENSE and AUTHOR:

Author:: Joshua Timberman (<joshua@opscode.com>)
Copyright:: 2009, Opscode, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
3 changes: 3 additions & 0 deletions attributes/kickstart.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
kickstart Mash.new unless attribute?("kickstart")
kickstart[:rootpw] = nil unless kickstart.has_key?(:rootpw)
kickstart[:virtual_host_name] = "build.#{node[:domain]}" unless kickstart.has_key?(:virtual_host_name)
7 changes: 7 additions & 0 deletions metadata.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
maintainer "Opscode"
maintainer_email "cookbooks@opscode.com"
license "Apache 2.0"
description "Installs/Configures kickstart"
long_description IO.read(File.join(File.dirname(__FILE__), 'README.rdoc'))
version "0.2"
depends "apache2"
18 changes: 18 additions & 0 deletions recipes/default.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#
# Cookbook Name:: kickstart
# Recipe:: default
#
# Copyright 2009, Opscode
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
52 changes: 52 additions & 0 deletions recipes/server.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#
# Cookbook Name:: kickstart
# Recipe:: server
#
# Copyright 2009, Opscode
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
include_recipe "apache2"

directory "/srv/kickstart" do
owner "root"
group "root"
mode "0755"
end

template "/srv/kickstart/ks.cfg" do
source "ks.cfg.erb"
mode "0644"
owner "root"
group "root"
end

link "/srv/kickstart/index.html" do
to "/srv/kickstart/ks.cfg"
end

template "#{node[:apache][:dir]}/sites-available/kickstart.conf" do
source "kickstart.conf.erb"
variables(
:virtual_host_name => node[:kickstart][:virtual_host_name],
:docroot => "/srv/kickstart"
)
mode "0644"
owner "root"
group "root"
end

apache_site "kickstart.conf" do
enable true
end

27 changes: 27 additions & 0 deletions templates/default/kickstart.conf.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<VirtualHost *:80>

DocumentRoot <%= @docroot %>

ServerName <%= @virtual_host_name %>
ServerAlias <%= @virtual_host_name.split('.')[0] %>

<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>

LogLevel info
ErrorLog <%= @node[:apache][:dir] %>/kickstart-error.log
CustomLog <%= @node[:apache][:dir] %>/kickstart-access.log combined

<Directory <%= @docroot %>>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>

AddOutputFilterByType DEFLATE text/html text/plain text/xml

</VirtualHost>

Loading

0 comments on commit d8b536a

Please sign in to comment.