stork 0.1.0.pre
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +21 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +10 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +75 -0
- data/LICENSE +201 -0
- data/README.md +61 -0
- data/Rakefile +25 -0
- data/bin/stork +97 -0
- data/bin/storkctl +62 -0
- data/lib/stork/builder.rb +104 -0
- data/lib/stork/client/plugins/host_install.rb +19 -0
- data/lib/stork/client/plugins/host_list.rb +12 -0
- data/lib/stork/client/plugins/host_localboot.rb +19 -0
- data/lib/stork/client/plugins/host_show.rb +19 -0
- data/lib/stork/collection/base.rb +45 -0
- data/lib/stork/collection/chefs.rb +6 -0
- data/lib/stork/collection/distros.rb +6 -0
- data/lib/stork/collection/hosts.rb +6 -0
- data/lib/stork/collection/layouts.rb +6 -0
- data/lib/stork/collection/networks.rb +6 -0
- data/lib/stork/collection/snippets.rb +6 -0
- data/lib/stork/collection/templates.rb +6 -0
- data/lib/stork/collections.rb +38 -0
- data/lib/stork/configuration.rb +98 -0
- data/lib/stork/deploy/command.rb +59 -0
- data/lib/stork/deploy/install_script.rb +39 -0
- data/lib/stork/deploy/kickstart_binding.rb +222 -0
- data/lib/stork/deploy/section.rb +30 -0
- data/lib/stork/deploy/snippet_binding.rb +49 -0
- data/lib/stork/plugin.rb +54 -0
- data/lib/stork/pxe.rb +70 -0
- data/lib/stork/resource/base.rb +42 -0
- data/lib/stork/resource/chef.rb +81 -0
- data/lib/stork/resource/delegator.rb +50 -0
- data/lib/stork/resource/distro.rb +30 -0
- data/lib/stork/resource/firewall.rb +47 -0
- data/lib/stork/resource/host.rb +202 -0
- data/lib/stork/resource/interface.rb +125 -0
- data/lib/stork/resource/layout.rb +50 -0
- data/lib/stork/resource/logical_volume.rb +49 -0
- data/lib/stork/resource/network.rb +36 -0
- data/lib/stork/resource/partition.rb +47 -0
- data/lib/stork/resource/password.rb +26 -0
- data/lib/stork/resource/repo.rb +29 -0
- data/lib/stork/resource/snippet.rb +20 -0
- data/lib/stork/resource/template.rb +24 -0
- data/lib/stork/resource/timezone.rb +31 -0
- data/lib/stork/resource/volume_group.rb +31 -0
- data/lib/stork/resources.rb +17 -0
- data/lib/stork/server/application.rb +127 -0
- data/lib/stork/server/control.rb +38 -0
- data/lib/stork/version.rb +4 -0
- data/lib/stork.rb +30 -0
- data/specs/builder_spec.rb +14 -0
- data/specs/collections_spec.rb +72 -0
- data/specs/configuration_spec.rb +151 -0
- data/specs/keys/snakeoil-root.pem +27 -0
- data/specs/keys/snakeoil-validation.pem +27 -0
- data/specs/kickstart_spec.rb +36 -0
- data/specs/pxe_spec.rb +57 -0
- data/specs/resource_chef_spec.rb +122 -0
- data/specs/resource_distro_spec.rb +38 -0
- data/specs/resource_firewall_spec.rb +71 -0
- data/specs/resource_host_spec.rb +323 -0
- data/specs/resource_interface_spec.rb +158 -0
- data/specs/resource_layout_spec.rb +78 -0
- data/specs/resource_logical_volume_spec.rb +44 -0
- data/specs/resource_network_spec.rb +45 -0
- data/specs/resource_partition_spec.rb +51 -0
- data/specs/resource_password_spec.rb +10 -0
- data/specs/resource_repo_spec.rb +43 -0
- data/specs/resource_snippet_spec.rb +10 -0
- data/specs/resource_template_spec.rb +5 -0
- data/specs/resource_timezone_spec.rb +5 -0
- data/specs/resource_volume_group_spec.rb +23 -0
- data/specs/scripts/kssetup.sh +24 -0
- data/specs/scripts/ksvalidate.sh +21 -0
- data/specs/server_spec.rb +84 -0
- data/specs/spec_helper.rb +33 -0
- data/specs/stork/authorized_keys +1 -0
- data/specs/stork/bundles/chefs/default.rb +9 -0
- data/specs/stork/bundles/distros/centos.rb +5 -0
- data/specs/stork/bundles/hosts/example.org.rb +66 -0
- data/specs/stork/bundles/layouts/home.rb +33 -0
- data/specs/stork/bundles/networks/local.rb +6 -0
- data/specs/stork/bundles/networks/org.rb +7 -0
- data/specs/stork/bundles/snippets/authorized-keys.erb +10 -0
- data/specs/stork/bundles/snippets/chef-bootstrap.erb +104 -0
- data/specs/stork/bundles/snippets/chef-reconfigure.erb +22 -0
- data/specs/stork/bundles/snippets/etc-hosts.erb +6 -0
- data/specs/stork/bundles/snippets/network-config.erb +7 -0
- data/specs/stork/bundles/snippets/noop.erb +1 -0
- data/specs/stork/bundles/snippets/notify.erb +2 -0
- data/specs/stork/bundles/snippets/ntp.erb +2 -0
- data/specs/stork/bundles/snippets/resolv-conf.erb +6 -0
- data/specs/stork/bundles/snippets/setup.erb +1 -0
- data/specs/stork/bundles/templates/default.ks.erb +25 -0
- data/specs/stork/config.rb +11 -0
- data/stork.gemspec +35 -0
- metadata +329 -0
@@ -0,0 +1,10 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe "Stork::Resource::Password" do
|
4
|
+
it "should generate a new password every time value is accessed" do
|
5
|
+
password = Stork::Resource::Password.new
|
6
|
+
pass1 = password.value
|
7
|
+
pass2 = password.value
|
8
|
+
pass1.wont_equal pass2
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe "Stork::Resource::Repo" do
|
4
|
+
it "must create a repo" do
|
5
|
+
Stork::Resource::Repo.new.must_be_instance_of Stork::Resource::Repo
|
6
|
+
end
|
7
|
+
|
8
|
+
it "must respond to name" do
|
9
|
+
Stork::Resource::Repo.new.must_respond_to :name
|
10
|
+
end
|
11
|
+
|
12
|
+
it "must respond to the baseurl accessors" do
|
13
|
+
Stork::Resource::Repo.new.must_respond_to :baseurl
|
14
|
+
Stork::Resource::Repo.new.must_respond_to :baseurl=
|
15
|
+
end
|
16
|
+
|
17
|
+
it "must respond to the mirrorlist accessors" do
|
18
|
+
Stork::Resource::Repo.new.must_respond_to :mirrorlist
|
19
|
+
Stork::Resource::Repo.new.must_respond_to :mirrorlist=
|
20
|
+
end
|
21
|
+
|
22
|
+
it "must only let either baseurl or mirrorlist" do
|
23
|
+
proc {
|
24
|
+
Stork::Resource::Repo.build 'updates', baseurl: 'foo', mirrorlist: 'foo'
|
25
|
+
}.must_raise(SyntaxError)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "must require either baseurl or mirrorlist" do
|
29
|
+
proc {
|
30
|
+
Stork::Resource::Repo.build 'updates'
|
31
|
+
}.must_raise(SyntaxError)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "must set the baseurl" do
|
35
|
+
repo = Stork::Resource::Repo.build('updates', baseurl: 'http://foo.com')
|
36
|
+
repo.baseurl.must_equal 'http://foo.com'
|
37
|
+
end
|
38
|
+
|
39
|
+
it "must set the mirrorlist" do
|
40
|
+
repo = Stork::Resource::Repo.build('updates', mirrorlist: 'http://foo.com')
|
41
|
+
repo.mirrorlist.must_equal 'http://foo.com'
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe "Stork::Resource::Snippet" do
|
4
|
+
it "must create a snippet" do
|
5
|
+
file = "./specs/stork/bundles/snippets/noop.erb"
|
6
|
+
snippet = Stork::Resource::Snippet.new(file)
|
7
|
+
snippet.name.must_equal "noop"
|
8
|
+
snippet.content.must_equal "# Default Snippet\n"
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe "Stork::Resource::VolumeGroup" do
|
4
|
+
it "should be created" do
|
5
|
+
Stork::Resource::VolumeGroup.new('/').must_be_instance_of Stork::Resource::VolumeGroup
|
6
|
+
end
|
7
|
+
|
8
|
+
it "must respond to name" do
|
9
|
+
Stork::Resource::VolumeGroup.new('/').must_respond_to :name
|
10
|
+
end
|
11
|
+
|
12
|
+
it "must respond to the partition accessors" do
|
13
|
+
Stork::Resource::VolumeGroup.new('/').must_respond_to :partition
|
14
|
+
Stork::Resource::VolumeGroup.new('/').must_respond_to :partition=
|
15
|
+
end
|
16
|
+
|
17
|
+
it "must build" do
|
18
|
+
vg = Stork::Resource::VolumeGroup.build 'vg', part: 'pv.01'
|
19
|
+
vg.name.must_equal 'vg'
|
20
|
+
vg.partition.must_equal 'pv.01'
|
21
|
+
vg.logical_volumes.must_equal []
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
echo "Starting setup"
|
4
|
+
if [ "$TRAVIS" = "true" ] ; then
|
5
|
+
sudo ip install pycurl
|
6
|
+
sudo pip install urlgrabber
|
7
|
+
git clone git://git.fedorahosted.org/git/pykickstart.git
|
8
|
+
cd pykickstart
|
9
|
+
sudo python setup.py install
|
10
|
+
else
|
11
|
+
pip install virtualenv
|
12
|
+
echo "Creating virtual environment: ksvalidator"
|
13
|
+
virtualenv ksvalidator
|
14
|
+
cd ksvalidator
|
15
|
+
echo "Activating!!!"
|
16
|
+
source bin/activate
|
17
|
+
echo "Installing packages"
|
18
|
+
pip install pycurl
|
19
|
+
pip install urlgrabber
|
20
|
+
git clone git://git.fedorahosted.org/git/pykickstart.git
|
21
|
+
cd pykickstart
|
22
|
+
python setup.py install
|
23
|
+
fi
|
24
|
+
echo "Setup complete"
|
@@ -0,0 +1,21 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
TESTPATH=$1
|
4
|
+
KSPATH=$2
|
5
|
+
VER=$3
|
6
|
+
mkdir -p $TESTPATH
|
7
|
+
cd $TESTPATH
|
8
|
+
|
9
|
+
if [ "$TRAVIS" != "true" ] ; then
|
10
|
+
if ! [ -f "./ksvalidator/bin/activate" ] ; then
|
11
|
+
echo "Please run 'rake ksvalidator:setup' to ensure that the virtual"
|
12
|
+
echo "environment is set up before running the integration tests or set"
|
13
|
+
echo "NOVALIDATE before you run"
|
14
|
+
exit 1
|
15
|
+
fi
|
16
|
+
cd ksvalidator
|
17
|
+
source bin/activate
|
18
|
+
fi
|
19
|
+
|
20
|
+
ksvalidator -e -v $VER $KSPATH
|
21
|
+
exit $?
|
@@ -0,0 +1,84 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
require 'sinatra'
|
4
|
+
require 'rack/test'
|
5
|
+
|
6
|
+
include Rack::Test::Methods
|
7
|
+
|
8
|
+
def app
|
9
|
+
b = Stork::Builder.load(configuration)
|
10
|
+
a = Stork::Server::Application
|
11
|
+
a.set :collection, b.collection
|
12
|
+
a.set :config, configuration
|
13
|
+
a
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "Stork::Server::Application" do
|
17
|
+
before(:each) do
|
18
|
+
FileUtils.mkdir('./specs/tmp/pxeboot')
|
19
|
+
end
|
20
|
+
|
21
|
+
after(:each) do
|
22
|
+
FileUtils.rm_rf(Dir.glob('./specs/tmp/*'))
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should respond to the root" do
|
26
|
+
get '/'
|
27
|
+
message = "{ \"status\":\"200\", \"message\": \"Stork Version #{Stork::VERSION} - #{Stork::CODENAME}\" }"
|
28
|
+
last_response.body.must_equal message
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should output the kickstart file for a valid host" do
|
32
|
+
get '/host/server.example.org'
|
33
|
+
message = "foo"
|
34
|
+
last_response.body.wont_equal "{ \"status\":\"404\", \"message\": \"not found\" }"
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should error for invalid host" do
|
38
|
+
get '/host/invalid.org'
|
39
|
+
message = "{ \"status\":\"404\", \"message\": \"not found\" }"
|
40
|
+
last_response.body.must_equal message
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should notify of a completed install" do
|
44
|
+
get '/host/server.example.org/installed'
|
45
|
+
last_response.body.must_equal "{ \"status\":\"200\", \"message\": \"OK\" }"
|
46
|
+
|
47
|
+
expected_content = <<-EOS
|
48
|
+
DEFAULT local
|
49
|
+
PROMPT 0
|
50
|
+
TIMEOUT 0
|
51
|
+
TOTALTIMEOUT 0
|
52
|
+
ONTIMEOUT local
|
53
|
+
LABEL local
|
54
|
+
LOCALBOOT -1
|
55
|
+
EOS
|
56
|
+
File.read("./specs/tmp/pxeboot/01-00-11-22-33-44-55").must_equal expected_content
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should error on completed install for invalid host" do
|
60
|
+
get '/host/invalid.org/installed'
|
61
|
+
last_response.body.must_equal "{ \"status\":\"404\", \"message\": \"not found\" }"
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should notify of an install request" do
|
65
|
+
get '/host/server.example.org/install'
|
66
|
+
last_response.body.must_equal "{ \"status\":\"200\", \"message\": \"OK\" }"
|
67
|
+
|
68
|
+
expected_content = <<-EOS
|
69
|
+
default install
|
70
|
+
prompt 0
|
71
|
+
timeout 1
|
72
|
+
label install
|
73
|
+
kernel vmlinuz
|
74
|
+
ipappend 2
|
75
|
+
append initrd=initrd.img ksdevice=bootif priority=critical kssendmac ks=http://localhost:5000/host/server.example.org
|
76
|
+
EOS
|
77
|
+
File.read("./specs/tmp/pxeboot/01-00-11-22-33-44-55").must_equal expected_content
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should error for invalid host" do
|
81
|
+
get '/host/invalid.org/install'
|
82
|
+
last_response.body.must_equal "{ \"status\":\"404\", \"message\": \"not found\" }"
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
ENV['RACK_ENV'] = 'test'
|
2
|
+
|
3
|
+
if ENV['TRAVIS']
|
4
|
+
require 'coveralls'
|
5
|
+
Coveralls.wear!
|
6
|
+
elsif ENV['COVERAGE']
|
7
|
+
require 'simplecov'
|
8
|
+
SimpleCov.start do
|
9
|
+
['specs', 'vendor', 'lib/stork/server/control.rb'].each{ |f| add_filter f }
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
require 'stork'
|
16
|
+
require 'minitest/spec'
|
17
|
+
require 'minitest/autorun'
|
18
|
+
require 'minitest/pride'
|
19
|
+
require 'minitest/given'
|
20
|
+
require 'open3'
|
21
|
+
require 'fileutils'
|
22
|
+
|
23
|
+
if ENV['DEBUG']
|
24
|
+
require 'minitest/debugger'
|
25
|
+
end
|
26
|
+
|
27
|
+
def configuration
|
28
|
+
Stork::Configuration.from_file('./specs/stork/config.rb')
|
29
|
+
end
|
30
|
+
|
31
|
+
def collection
|
32
|
+
Stork::Builder.load(configuration).collection
|
33
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDjIoUKCW1ukJefYL4eS0/ZYMT8VSmhqvCD39bd93ur3qKpSx6El+kKPuviHr10INGtWy/0APkPFXBI2YVyzypjAdt4j6Owj/4YgPSmf1KYhT1cneEFdSDuHgP86BYVuxuZSFwX7hl+uBIYMYHf4Yt3x58jDiWJeLinxhavw7jIRczuuDl5EEo/uBtkisM1O4M2pcPs0uk8okVLH3pOdNE9s1lCNvnEP4uLr8juS54S6lYIdvabvoA64I/oxSeY5LASi4RE9NgHb6o0elmKwtD5iL/SDCZYM+jhd5LVGYv0q6luSjLtgyoh9hnah6+hIS8lmzc1H+d2fhpxS/VuGssZ rlyon@fakesystem.local
|
@@ -0,0 +1,9 @@
|
|
1
|
+
chef "default" do
|
2
|
+
url "https://chef.example.org"
|
3
|
+
version "11.6.0"
|
4
|
+
client_name "root"
|
5
|
+
client_key "./specs/keys/snakeoil-root.pem"
|
6
|
+
validator_name "chef-validator"
|
7
|
+
validation_key "./specs/keys/snakeoil-validation.pem"
|
8
|
+
encrypted_data_bag_secret "secretkey"
|
9
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# Config for example.org
|
2
|
+
host "server.example.org" do
|
3
|
+
template "default"
|
4
|
+
chef "default"
|
5
|
+
pxemac "00:11:22:33:44:55"
|
6
|
+
layout "home"
|
7
|
+
distro "centos"
|
8
|
+
repo "whamcloud-client", baseurl: "http://yum.example.com/eln/x86_64"
|
9
|
+
package "foo"
|
10
|
+
|
11
|
+
|
12
|
+
interface "eth0" do
|
13
|
+
bootproto :static
|
14
|
+
ip "99.99.1.8"
|
15
|
+
# network "org"
|
16
|
+
end
|
17
|
+
|
18
|
+
interface "eth1" do
|
19
|
+
bootproto :static
|
20
|
+
ip "192.168.1.10"
|
21
|
+
netmask "255.255.255.0"
|
22
|
+
gateway "192.168.1.1"
|
23
|
+
nameserver "192.168.1.253"
|
24
|
+
nameserver "192.168.1.252"
|
25
|
+
end
|
26
|
+
|
27
|
+
pre_snippet "setup"
|
28
|
+
post_snippet "ntp"
|
29
|
+
post_snippet "resolv-conf"
|
30
|
+
post_snippet "chef-bootstrap"
|
31
|
+
post_snippet "chef-reconfigure"
|
32
|
+
post_snippet "notify"
|
33
|
+
|
34
|
+
run_list %w{ role[base] recipe[apache] }
|
35
|
+
end
|
36
|
+
|
37
|
+
hosts=[
|
38
|
+
[10, "00:11:22:33:44:01"],
|
39
|
+
[11, "00:11:22:33:44:02"],
|
40
|
+
[12, "00:11:22:33:44:03"],
|
41
|
+
[13, "00:11:22:33:44:04"],
|
42
|
+
[14, "00:11:22:33:44:05"],
|
43
|
+
[15, "00:11:22:33:44:06"],
|
44
|
+
[16, "00:11:22:33:44:07"],
|
45
|
+
[17, "00:11:22:33:44:08"],
|
46
|
+
[18, "00:11:22:33:44:09"],
|
47
|
+
[19, "00:11:22:33:44:10"]
|
48
|
+
]
|
49
|
+
|
50
|
+
hosts.each do |octet, mac|
|
51
|
+
host "n0#{octet}.example.org" do
|
52
|
+
template "default"
|
53
|
+
chef "default"
|
54
|
+
distro "centos"
|
55
|
+
pxemac mac
|
56
|
+
layout "home"
|
57
|
+
|
58
|
+
|
59
|
+
interface "eth0" do
|
60
|
+
bootproto :static
|
61
|
+
ip "192.168.10.#{octet}"
|
62
|
+
network "org"
|
63
|
+
end
|
64
|
+
run_list %w{ role[node] }
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
layout "home" do
|
2
|
+
clearpart
|
3
|
+
zerombr
|
4
|
+
part "/boot" do
|
5
|
+
size 100
|
6
|
+
type "ext4"
|
7
|
+
primary
|
8
|
+
end
|
9
|
+
|
10
|
+
part "swap" do
|
11
|
+
recommended
|
12
|
+
type "swap"
|
13
|
+
primary
|
14
|
+
end
|
15
|
+
|
16
|
+
part "/" do
|
17
|
+
size 4096
|
18
|
+
type "ext4"
|
19
|
+
end
|
20
|
+
|
21
|
+
part "pv.01" do
|
22
|
+
size 1
|
23
|
+
grow
|
24
|
+
end
|
25
|
+
|
26
|
+
volume_group "vg", part: "pv.01" do
|
27
|
+
logical_volume "lv_home" do
|
28
|
+
path "/home"
|
29
|
+
size 1
|
30
|
+
grow
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
echo "Installing Chef"
|
2
|
+
|
3
|
+
cat > /etc/init.d/chef-firstboot << 'EOF'
|
4
|
+
#!/bin/bash
|
5
|
+
#
|
6
|
+
# chef-firstboot Chef first-boot script
|
7
|
+
#
|
8
|
+
# chkconfig: - 97 02
|
9
|
+
# description: Run chef for the first time using the /etc/chef/first-boot.json content.
|
10
|
+
|
11
|
+
### BEGIN INIT INFO
|
12
|
+
# Provides: chef-firstboot
|
13
|
+
# Required-Start: $local_fs $network $remote_fs
|
14
|
+
# Required-Stop: $local_fs $network $remote_fs
|
15
|
+
# Should-Start: $named $time
|
16
|
+
# Should-Stop: $named $time
|
17
|
+
# Short-Description: Chef first-boot script
|
18
|
+
# Description: Run chef for the first time using the /etc/chef/first-boot.json content.
|
19
|
+
### END INIT INFO
|
20
|
+
|
21
|
+
exec="/usr/bin/chef-client"
|
22
|
+
chk="/sbin/chkconfig"
|
23
|
+
|
24
|
+
start() {
|
25
|
+
$exec -j /etc/chef/first-boot.json -N <%= host.name %>
|
26
|
+
retval=$?
|
27
|
+
$chk chef-client on
|
28
|
+
$chk chef-firstboot off
|
29
|
+
return $retval
|
30
|
+
}
|
31
|
+
|
32
|
+
stop() {
|
33
|
+
return 0
|
34
|
+
}
|
35
|
+
|
36
|
+
restart() {
|
37
|
+
return 0
|
38
|
+
}
|
39
|
+
|
40
|
+
case "$1" in
|
41
|
+
start)
|
42
|
+
$1
|
43
|
+
;;
|
44
|
+
stop)
|
45
|
+
$1
|
46
|
+
;;
|
47
|
+
restart)
|
48
|
+
$1
|
49
|
+
;;
|
50
|
+
esac
|
51
|
+
exit $?
|
52
|
+
EOF
|
53
|
+
chmod 755 /etc/init.d/chef-firstboot
|
54
|
+
chkconfig chef-firstboot on
|
55
|
+
|
56
|
+
bash -c '
|
57
|
+
exists() {
|
58
|
+
if command -v $1 &>/dev/null
|
59
|
+
then
|
60
|
+
return 0
|
61
|
+
else
|
62
|
+
return 1
|
63
|
+
fi
|
64
|
+
}
|
65
|
+
|
66
|
+
install_sh="https://www.opscode.com/chef/install.sh"
|
67
|
+
version_string="-v <%= chef.version %>"
|
68
|
+
if ! exists /usr/bin/chef-client; then
|
69
|
+
if exists wget; then
|
70
|
+
wget ${install_sh} -O /tmp/install_sh
|
71
|
+
elif exists curl; then
|
72
|
+
curl ${install_sh} > /tmp/install.sh
|
73
|
+
else
|
74
|
+
echo "Neither wget nor curl found. Please install one and try again." >&2
|
75
|
+
exit 1
|
76
|
+
fi
|
77
|
+
fi
|
78
|
+
|
79
|
+
bash /tmp/install_sh ${version_string}
|
80
|
+
'
|
81
|
+
|
82
|
+
<% if chef.encrypted_data_bag_secret %>
|
83
|
+
cat > /etc/chef/encrypted_data_bag_secret << 'EOF'
|
84
|
+
<%= chef.encrypted_data_bag_secret %>
|
85
|
+
EOF
|
86
|
+
chmod 0600 /etc/chef/encrypted_data_bag_secret
|
87
|
+
<% end %>
|
88
|
+
|
89
|
+
mkdir -p /etc/chef
|
90
|
+
|
91
|
+
cat > /etc/chef/validation.pem << 'EOF'
|
92
|
+
<%= chef.validation_key %>
|
93
|
+
EOF
|
94
|
+
chmod 0644 /etc/chef/validation.pem
|
95
|
+
|
96
|
+
cat > /etc/chef/client.rb << 'EOF'
|
97
|
+
<%= chef.client_content %>
|
98
|
+
EOF
|
99
|
+
chmod 644 /etc/chef/client.rb
|
100
|
+
|
101
|
+
cat > /etc/chef/first-boot.json << 'EOF'
|
102
|
+
<%= first_boot_content %>
|
103
|
+
EOF
|
104
|
+
chmod 644 /etc/chef/first-boot.json
|
@@ -0,0 +1,22 @@
|
|
1
|
+
echo "Setting up knife"
|
2
|
+
mkdir /root/.chef
|
3
|
+
chmod 700 /root/.chef
|
4
|
+
|
5
|
+
cat > /root/.chef/<%= chef.client_name %>.pem << 'EOF'
|
6
|
+
<%= chef.client_key %>
|
7
|
+
EOF
|
8
|
+
chmod 600 /root/.chef/<%= chef.client_name %>.pem
|
9
|
+
|
10
|
+
cat > /root/.chef/knife.rb << 'EOF'
|
11
|
+
<%= chef.knife_content %>
|
12
|
+
EOF
|
13
|
+
chmod 600 /root/.chef/knife.rb
|
14
|
+
|
15
|
+
echo "Reregistering client"
|
16
|
+
knife client reregister <%= host.name %> -f /etc/chef/client.pem --config /root/.chef/knife.rb
|
17
|
+
|
18
|
+
echo "Getting rid of the root pem"
|
19
|
+
rm /root/.chef/root.pem
|
20
|
+
|
21
|
+
echo "Getting rid of the knife config"
|
22
|
+
rm /root/.chef/knife.rb
|
@@ -0,0 +1,6 @@
|
|
1
|
+
cat > /etc/hosts << 'EOF'
|
2
|
+
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
|
3
|
+
127.0.0.1 <%= host.name %> <%= host.name.split('.').first %>
|
4
|
+
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
|
5
|
+
::1 <%= host.name %> <%= host.name.split('.').first %>
|
6
|
+
EOF
|
@@ -0,0 +1 @@
|
|
1
|
+
# Default Snippet
|
@@ -0,0 +1 @@
|
|
1
|
+
# Setting up <%= host.name %>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
#######################################
|
2
|
+
### Kickstart generated by stork ###
|
3
|
+
#######################################
|
4
|
+
install
|
5
|
+
reboot
|
6
|
+
text
|
7
|
+
skipx
|
8
|
+
firstboot --disable
|
9
|
+
lang en_US
|
10
|
+
keyboard us
|
11
|
+
|
12
|
+
<%= pre_snippets %>
|
13
|
+
|
14
|
+
<%= url %>
|
15
|
+
<%= network %>
|
16
|
+
<%= password %>
|
17
|
+
<%= firewall %>
|
18
|
+
<%= timezone %>
|
19
|
+
<%= selinux %>
|
20
|
+
<%= layout %>
|
21
|
+
<%= repos %>
|
22
|
+
|
23
|
+
<%= packages %>
|
24
|
+
|
25
|
+
<%= post_snippets %>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# Stork configuration file"
|
2
|
+
path "./specs/stork"
|
3
|
+
bundle_path "./specs/stork/bundles"
|
4
|
+
authorized_keys_file "./specs/stork/authorized_keys"
|
5
|
+
pxe_path "./specs/tmp/pxeboot"
|
6
|
+
log_file "./specs/tmp/stork.log"
|
7
|
+
pid_file "./specs/tmp/stork.pid"
|
8
|
+
server "localhost"
|
9
|
+
port 5000
|
10
|
+
bind "0.0.0.0"
|
11
|
+
timezone "America/New_York"
|
data/stork.gemspec
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'stork/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "stork"
|
8
|
+
spec.version = Stork::VERSION
|
9
|
+
spec.authors = ["Rob Lyon"]
|
10
|
+
spec.email = ["nosignsoflifehere@gmail.com"]
|
11
|
+
spec.summary = %q{Autoinstallation and PXE management.}
|
12
|
+
spec.description = %q{Autoinstallation and PXE management for Redhat/CentOS based system deployment.}
|
13
|
+
spec.homepage = "https://github.com/rlyon/stork"
|
14
|
+
spec.license = "Apache2"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_runtime_dependency "sinatra"
|
22
|
+
spec.add_runtime_dependency "thin"
|
23
|
+
spec.add_runtime_dependency "sqlite3"
|
24
|
+
spec.add_runtime_dependency "rest-client"
|
25
|
+
spec.add_runtime_dependency "highline"
|
26
|
+
|
27
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
28
|
+
spec.add_development_dependency "rake"
|
29
|
+
spec.add_development_dependency "minitest", "~> 4.7.3"
|
30
|
+
spec.add_development_dependency "rack-test"
|
31
|
+
spec.add_development_dependency "simplecov"
|
32
|
+
spec.add_development_dependency "coveralls"
|
33
|
+
spec.add_development_dependency "minitest-given"
|
34
|
+
spec.add_development_dependency "minitest-debugger"
|
35
|
+
end
|