stork 0.2.0.pre → 0.3.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 +4 -4
- data/.ruby-version +1 -1
- data/.travis.yml +6 -6
- data/README.md +1 -53
- data/Rakefile +1 -3
- data/lib/stork/builder.rb +1 -15
- data/lib/stork/client/plugins/host_show.rb +0 -2
- data/lib/stork/collections.rb +0 -4
- data/lib/stork/configuration.rb +0 -1
- data/lib/stork/database.rb +1 -1
- data/lib/stork/deploy/snippet_binding.rb +0 -10
- data/lib/stork/plugin.rb +1 -1
- data/lib/stork/resource/base.rb +25 -0
- data/lib/stork/resource/host.rb +15 -31
- data/lib/stork/resource/interface.rb +1 -1
- data/lib/stork/resource/network.rb +12 -0
- data/lib/stork/resources.rb +0 -1
- data/lib/stork/version.rb +1 -1
- data/specs/builder_spec.rb +0 -1
- data/specs/collections_spec.rb +0 -4
- data/specs/kickstart_spec.rb +2 -3
- data/specs/resource_host_spec.rb +19 -27
- data/specs/resource_interface_spec.rb +22 -1
- data/specs/resource_layout_spec.rb +3 -3
- data/specs/resource_network_spec.rb +56 -0
- data/specs/scripts/kssetup.sh +13 -21
- data/specs/scripts/ksvalidate.sh +9 -14
- data/specs/scripts/requirements.txt +8 -0
- data/specs/server_spec.rb +2 -2
- data/specs/stork/bundles/hosts/example.org.rb +5 -16
- data/specs/stork/bundles/networks/internal-one.rb +7 -0
- data/specs/stork/bundles/networks/internal-two.rb +3 -0
- metadata +41 -52
- data/.ruby-gemset +0 -1
- data/box/Vagrantfile +0 -41
- data/box/bootstrap.sh +0 -317
- data/box/integration.sh +0 -33
- data/lib/stork/collection/chefs.rb +0 -6
- data/lib/stork/resource/chef.rb +0 -81
- data/specs/deploy_snippet_binding_spec.rb +0 -15
- data/specs/resource_chef_spec.rb +0 -122
- data/specs/stork/bundles/chefs/default.rb +0 -9
- data/specs/stork/bundles/networks/local.rb +0 -6
- data/specs/stork/bundles/networks/org.rb +0 -7
- data/specs/stork/bundles/snippets/chef-bootstrap.erb +0 -104
- data/specs/stork/bundles/snippets/chef-reconfigure.erb +0 -22
data/box/integration.sh
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
#!/bin/sh
|
2
|
-
|
3
|
-
# Make sure that virtualbox is not running dhcp on the host interface
|
4
|
-
VBoxManage dhcpserver remove --netname HostInterfaceNetworking-vboxnet0
|
5
|
-
|
6
|
-
ID=$(date "+%Y%M%H%m%d%S")
|
7
|
-
MAC=$(echo $1 | sed 's/://g' | tr '[:lower:]' '[:upper:]')
|
8
|
-
|
9
|
-
VBoxManage createvm --name stork_pxe_$ID --ostype RedHat_64 --register
|
10
|
-
|
11
|
-
VBoxManage createhd --filename stork_pxe_$ID.vmdk --format VMDK --size 4000 --variant Standard
|
12
|
-
VBoxManage storagectl stork_pxe_$ID --name "IDE Controller" --add ide --controller PIIX4 --hostiocache on --bootable on
|
13
|
-
VBoxManage storageattach stork_pxe_$ID --storagectl "IDE Controller" --port 0 --device 0 --type hdd --medium stork_pxe_$ID.vmdk
|
14
|
-
|
15
|
-
VBoxManage modifyvm stork_pxe_$ID --nic1 hostonly
|
16
|
-
VBoxManage modifyvm stork_pxe_$ID --cableconnected1 on
|
17
|
-
VBoxManage modifyvm stork_pxe_$ID --hostonlyadapter1 vboxnet0
|
18
|
-
VBoxManage modifyvm stork_pxe_$ID --macaddress1 $MAC
|
19
|
-
VBoxManage modifyvm stork_pxe_$ID --nictype1 82540EM
|
20
|
-
VBoxManage modifyvm stork_pxe_$ID --intnet1 intnet
|
21
|
-
|
22
|
-
VBoxManage modifyvm stork_pxe_$ID --boot1 net
|
23
|
-
VBoxManage modifyvm stork_pxe_$ID --boot2 disk
|
24
|
-
VBoxManage modifyvm stork_pxe_$ID --boot3 none
|
25
|
-
VBoxManage modifyvm stork_pxe_$ID --boot4 none
|
26
|
-
|
27
|
-
VBoxManage modifyvm stork_pxe_$ID --memory 1024
|
28
|
-
|
29
|
-
VBoxManage modifyvm stork_pxe_$ID --acpi on
|
30
|
-
VBoxManage modifyvm stork_pxe_$ID --ioapic on
|
31
|
-
VBoxManage modifyvm stork_pxe_$ID --rtcuseutc on
|
32
|
-
|
33
|
-
VBoxManage startvm stork_pxe_$ID
|
data/lib/stork/resource/chef.rb
DELETED
@@ -1,81 +0,0 @@
|
|
1
|
-
module Stork
|
2
|
-
module Resource
|
3
|
-
class Chef < Base
|
4
|
-
attr_accessor :url
|
5
|
-
attr_accessor :version
|
6
|
-
attr_accessor :client_name
|
7
|
-
attr_accessor :validator_name
|
8
|
-
attr_accessor :client_key
|
9
|
-
attr_accessor :validation_key
|
10
|
-
attr_accessor :encrypted_data_bag_secret
|
11
|
-
|
12
|
-
def setup
|
13
|
-
@url = nil
|
14
|
-
@version = nil
|
15
|
-
@client_name = "root"
|
16
|
-
@validator_name = "chef-validator"
|
17
|
-
@validation_key = nil
|
18
|
-
@client_key = nil
|
19
|
-
@encrypted_data_bag_secret = nil
|
20
|
-
end
|
21
|
-
|
22
|
-
def validate!
|
23
|
-
# I should make sure that I'm at least getting the url,
|
24
|
-
# version, and the files.
|
25
|
-
require_value(:url)
|
26
|
-
require_value(:version)
|
27
|
-
require_value(:validation_key)
|
28
|
-
require_value(:client_key)
|
29
|
-
end
|
30
|
-
|
31
|
-
def client_content
|
32
|
-
<<-EOF
|
33
|
-
log_level :auto
|
34
|
-
log_location STDOUT
|
35
|
-
chef_server_url '#{url}'
|
36
|
-
validation_client_name '#{validator_name}'
|
37
|
-
# Using default node name (fqdn)
|
38
|
-
EOF
|
39
|
-
end
|
40
|
-
|
41
|
-
def knife_content
|
42
|
-
<<-EOF
|
43
|
-
log_level :info
|
44
|
-
log_location STDOUT
|
45
|
-
node_name '#{client_name}'
|
46
|
-
client_key '/root/.chef/#{client_name}.pem'
|
47
|
-
validation_client_name '#{validator_name}'
|
48
|
-
validation_key '/etc/chef/validation.pem'
|
49
|
-
chef_server_url '#{url}'
|
50
|
-
cache_type 'BasicFile'
|
51
|
-
cache_options( :path => '/root/.chef/checksums' )
|
52
|
-
EOF
|
53
|
-
end
|
54
|
-
|
55
|
-
class ChefDelegator < Stork::Resource::Delegator
|
56
|
-
file :client_key
|
57
|
-
file :validation_key
|
58
|
-
|
59
|
-
def url(url)
|
60
|
-
delegated.url = url
|
61
|
-
end
|
62
|
-
|
63
|
-
def version(version)
|
64
|
-
delegated.version = version
|
65
|
-
end
|
66
|
-
|
67
|
-
def client_name(client_name)
|
68
|
-
delegated.client_name = client_name
|
69
|
-
end
|
70
|
-
|
71
|
-
def validator_name(validator_name)
|
72
|
-
delegated.validator_name = validator_name
|
73
|
-
end
|
74
|
-
|
75
|
-
def encrypted_data_bag_secret(secret)
|
76
|
-
delegated.encrypted_data_bag_secret = secret
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
|
2
|
-
require File.dirname(__FILE__) + '/spec_helper'
|
3
|
-
|
4
|
-
describe "Stork::Deploy::SnippetBinding" do
|
5
|
-
before(:each) do
|
6
|
-
load_config
|
7
|
-
end
|
8
|
-
|
9
|
-
it "must create a valid first boot file for chef" do
|
10
|
-
host = collection.hosts.get("server.example.org")
|
11
|
-
binding = Stork::Deploy::SnippetBinding.new(host)
|
12
|
-
first_boot_content = "{\"run_list\":[\"role[base]\",\"recipe[apache]\"]}"
|
13
|
-
binding.first_boot_content.must_equal first_boot_content
|
14
|
-
end
|
15
|
-
end
|
data/specs/resource_chef_spec.rb
DELETED
@@ -1,122 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
-
|
3
|
-
describe "Chef" do
|
4
|
-
it "should be created" do
|
5
|
-
Stork::Resource::Chef.new("test").must_be_instance_of Stork::Resource::Chef
|
6
|
-
end
|
7
|
-
|
8
|
-
it "should respond to the name method" do
|
9
|
-
Stork::Resource::Chef.new("test").must_respond_to :name
|
10
|
-
end
|
11
|
-
|
12
|
-
it "should respond to the url accessors" do
|
13
|
-
Stork::Resource::Chef.new("test").must_respond_to :url
|
14
|
-
Stork::Resource::Chef.new("test").must_respond_to :url=
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should respond to the version accessors" do
|
18
|
-
Stork::Resource::Chef.new("test").must_respond_to :version
|
19
|
-
Stork::Resource::Chef.new("test").must_respond_to :version=
|
20
|
-
end
|
21
|
-
|
22
|
-
it "should respond to the client_key accessors" do
|
23
|
-
Stork::Resource::Chef.new("test").must_respond_to :client_key
|
24
|
-
Stork::Resource::Chef.new("test").must_respond_to :client_key=
|
25
|
-
end
|
26
|
-
|
27
|
-
it "should respond to the client_name accessors" do
|
28
|
-
Stork::Resource::Chef.new("test").must_respond_to :client_name
|
29
|
-
Stork::Resource::Chef.new("test").must_respond_to :client_name=
|
30
|
-
end
|
31
|
-
|
32
|
-
it "should respond to the validator_name accessors" do
|
33
|
-
Stork::Resource::Chef.new("test").must_respond_to :validator_name
|
34
|
-
Stork::Resource::Chef.new("test").must_respond_to :validator_name=
|
35
|
-
end
|
36
|
-
|
37
|
-
it "should respond to the validation_key accessors" do
|
38
|
-
Stork::Resource::Chef.new("test").must_respond_to :validation_key
|
39
|
-
Stork::Resource::Chef.new("test").must_respond_to :validation_key=
|
40
|
-
end
|
41
|
-
|
42
|
-
it "should respond to the encrypted_data_bag_secret accessors" do
|
43
|
-
Stork::Resource::Chef.new("test").must_respond_to :encrypted_data_bag_secret
|
44
|
-
Stork::Resource::Chef.new("test").must_respond_to :encrypted_data_bag_secret=
|
45
|
-
end
|
46
|
-
|
47
|
-
it "should require url" do
|
48
|
-
proc {
|
49
|
-
ckey = "./specs/keys/snakeoil-root.pem"
|
50
|
-
vkey = "./specs/keys/snakeoil-validation.pem"
|
51
|
-
|
52
|
-
chef = Stork::Resource::Chef.build("test") do
|
53
|
-
version "11.4.4"
|
54
|
-
client_key ckey
|
55
|
-
validation_key vkey
|
56
|
-
end
|
57
|
-
}.must_raise(SyntaxError)
|
58
|
-
end
|
59
|
-
|
60
|
-
it "should require version" do
|
61
|
-
proc {
|
62
|
-
ckey = "./specs/keys/snakeoil-root.pem"
|
63
|
-
vkey = "./specs/keys/snakeoil-validation.pem"
|
64
|
-
|
65
|
-
chef = Stork::Resource::Chef.build("test") do
|
66
|
-
url "https://chef.example.org"
|
67
|
-
client_key ckey
|
68
|
-
validation_key vkey
|
69
|
-
end
|
70
|
-
}.must_raise(SyntaxError)
|
71
|
-
end
|
72
|
-
|
73
|
-
it "should require client_key" do
|
74
|
-
proc {
|
75
|
-
ckey = "./specs/keys/snakeoil-root.pem"
|
76
|
-
vkey = "./specs/keys/snakeoil-validation.pem"
|
77
|
-
|
78
|
-
chef = Stork::Resource::Chef.build("test") do
|
79
|
-
url "https://chef.example.org"
|
80
|
-
version "11.4.4"
|
81
|
-
validation_key vkey
|
82
|
-
end
|
83
|
-
}.must_raise(SyntaxError)
|
84
|
-
end
|
85
|
-
|
86
|
-
it "should require validation_key" do
|
87
|
-
proc {
|
88
|
-
ckey = "./specs/keys/snakeoil-root.pem"
|
89
|
-
vkey = "./specs/keys/snakeoil-validation.pem"
|
90
|
-
|
91
|
-
chef = Stork::Resource::Chef.build("test") do
|
92
|
-
url "https://chef.example.org"
|
93
|
-
version "11.4.4"
|
94
|
-
client_key ckey
|
95
|
-
end
|
96
|
-
}.must_raise(SyntaxError)
|
97
|
-
end
|
98
|
-
|
99
|
-
it "should build" do
|
100
|
-
ckey = "./specs/keys/snakeoil-root.pem"
|
101
|
-
vkey = "./specs/keys/snakeoil-validation.pem"
|
102
|
-
|
103
|
-
chef = Stork::Resource::Chef.build("test") do
|
104
|
-
url "https://chef.example.org"
|
105
|
-
version "11.4.4"
|
106
|
-
client_name "root"
|
107
|
-
client_key ckey
|
108
|
-
validator_name "validator"
|
109
|
-
validation_key vkey
|
110
|
-
encrypted_data_bag_secret "secret"
|
111
|
-
end
|
112
|
-
|
113
|
-
chef.name.must_equal "test"
|
114
|
-
chef.url.must_equal "https://chef.example.org"
|
115
|
-
chef.version.must_equal "11.4.4"
|
116
|
-
chef.client_name.must_equal "root"
|
117
|
-
chef.client_key.must_equal File.read(ckey)
|
118
|
-
chef.validator_name.must_equal "validator"
|
119
|
-
chef.validation_key.must_equal File.read(vkey)
|
120
|
-
chef.encrypted_data_bag_secret.must_equal "secret"
|
121
|
-
end
|
122
|
-
end
|
@@ -1,9 +0,0 @@
|
|
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
|
@@ -1,104 +0,0 @@
|
|
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
|
@@ -1,22 +0,0 @@
|
|
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
|