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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb70dddbdd8452f89e72c5430a152525ffde4a8d
|
4
|
+
data.tar.gz: 9f4ea640d74fb77973d86abee6c564067a1433f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11a458fd20ac0204fcaba0fc150495321023017411123ca7acc5d11c2ea7e4f88609db88a98fae780f0823d0a7a0c3dd56a2acb4eac1ca1c676bcfcab87de73f
|
7
|
+
data.tar.gz: 1b84d3ebeb8cfc2f3f5aa5e960830717b053f107facbf51fdecad700da0b76b3fa29daf20409ae52c8bc1ee347a5b34171e3a0e113dd6c36d0fb9c2c9225c2e7
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.4.4
|
data/.travis.yml
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
-
- 2.
|
4
|
-
- 2.0.0
|
5
|
-
- 1.9.3
|
3
|
+
- 2.4.0
|
6
4
|
|
7
|
-
|
5
|
+
sudo: false
|
6
|
+
dist: trusty
|
7
|
+
|
8
|
+
before_script:
|
9
|
+
- rake ksvalidator:setup
|
8
10
|
|
9
|
-
notifications:
|
10
|
-
hipchat: ac943dbb9ee5b4a2562d4476987a91@Stork
|
data/README.md
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
[](https://travis-ci.org/rlyon/stork)
|
3
3
|
[](https://coveralls.io/r/rlyon/stork)
|
4
4
|
[](https://codeclimate.com/github/rlyon/stork)
|
5
|
+
[](https://rubygems.org/gems/stork)
|
5
6
|
|
6
7
|
Stork is a autoinstall utility, kickstart generation tool and server for CentOS and Redhat systems. It aims to fill the gap in the bare metal systems deployment that many of the other tools for cloud and virtual systems excel at.
|
7
8
|
|
@@ -54,7 +55,6 @@ where
|
|
54
55
|
|
55
56
|
* ```layout``` - Disk layout containing partition and volume group information. You can supply a string or a block value. If a string is supplied stork will attempt to find the id matching a previously defined layout.
|
56
57
|
* ```template``` - The kickstart template to use when generating the autoinstallation instructions
|
57
|
-
* ```chef``` - Chef server information. You can supply a string or a block value. If a string is supplied stork will attempt to find the id matching a previously defined chef server.
|
58
58
|
* ```pxemac``` - The mac address of the PXE enabled interface. Used to create the boot configuration files.
|
59
59
|
* ```pre_snippet``` - Scripts that will be run in the **pre** section before the install begins. Snippets are accessed by the basename of the file they are stored in.
|
60
60
|
* ```post_snippet``` - Scripts that will be run in the **post** section afer the install has successfully completed. Snippets are accessed by the basename of the file they are stored in.
|
@@ -64,8 +64,6 @@ where
|
|
64
64
|
* ```firewall``` - Initial firewall settings. Block only.
|
65
65
|
* ```selinux``` - String or symbol value representing the three selinux states. The only valid values are: enforcing, permissive, or disabled. Default is enforcing.
|
66
66
|
* ```package``` - Adds a package to the install. Generally not needed as the minimal set of packages that are installed by default will be enough to install the configuration management software.
|
67
|
-
* ```run_list``` - Chef runlist items that will populate the first-boot.json file. Can be an array or string value.
|
68
|
-
* ```chef_environment``` - A string value representing the chef environment the system is part of. Defaults to the '_default' environment.
|
69
67
|
* ```repos``` - Add a new repo to the host.
|
70
68
|
* ```stork``` - Url. Override the stork server location.
|
71
69
|
|
@@ -76,7 +74,6 @@ Typical hosts will look like:
|
|
76
74
|
```ruby
|
77
75
|
host "server.example.org" do
|
78
76
|
template "default"
|
79
|
-
chef "default"
|
80
77
|
pxemac "00:11:22:33:44:55"
|
81
78
|
layout "home"
|
82
79
|
distro "centos"
|
@@ -102,11 +99,7 @@ host "server.example.org" do
|
|
102
99
|
pre_snippet "setup"
|
103
100
|
post_snippet "ntp"
|
104
101
|
post_snippet "resolv-conf"
|
105
|
-
post_snippet "chef-bootstrap"
|
106
|
-
post_snippet "chef-reconfigure"
|
107
102
|
post_snippet "notify"
|
108
|
-
|
109
|
-
run_list %w{ role[base] recipe[apache] }
|
110
103
|
end
|
111
104
|
```
|
112
105
|
|
@@ -129,7 +122,6 @@ hosts=[
|
|
129
122
|
hosts.each do |octet, mac|
|
130
123
|
host "c0#{octet}.example.org" do
|
131
124
|
template "default"
|
132
|
-
chef "default"
|
133
125
|
distro "centos"
|
134
126
|
pxemac mac
|
135
127
|
layout "home"
|
@@ -140,7 +132,6 @@ hosts.each do |octet, mac|
|
|
140
132
|
ip "192.168.10.#{octet}"
|
141
133
|
network "org"
|
142
134
|
end
|
143
|
-
run_list %w{ role[node] }
|
144
135
|
end
|
145
136
|
end
|
146
137
|
```
|
@@ -463,48 +454,6 @@ firewall do
|
|
463
454
|
end
|
464
455
|
```
|
465
456
|
|
466
|
-
## Defining the chef resources
|
467
|
-
|
468
|
-
### ```chef```
|
469
|
-
|
470
|
-
#### Syntax:
|
471
|
-
|
472
|
-
The syntax for the **chef** resource is as follows:
|
473
|
-
|
474
|
-
```ruby
|
475
|
-
chef "name" do
|
476
|
-
attribute "value"
|
477
|
-
end
|
478
|
-
```
|
479
|
-
|
480
|
-
where
|
481
|
-
|
482
|
-
* ```name``` is a unique name that can be used to define global resources that can be referenced from other resources by the defined name.
|
483
|
-
* ```attribute``` is the attributes available for this resource
|
484
|
-
|
485
|
-
#### Attributes:
|
486
|
-
|
487
|
-
* ```version``` - The version of chef to use.
|
488
|
-
* ```client_name``` - The admin client name.
|
489
|
-
* ```client_key``` - The admin client key file.
|
490
|
-
* ```validator_name``` - The validation client name.
|
491
|
-
* ```validation_key``` - The validation key file.
|
492
|
-
* ```encrypted_data_bag_secret``` - A string value of the data bag encryption key.
|
493
|
-
|
494
|
-
#### Examples:
|
495
|
-
|
496
|
-
```ruby
|
497
|
-
chef "default" do
|
498
|
-
url "https://chef.example.org"
|
499
|
-
version "11.6.0"
|
500
|
-
client_name "root"
|
501
|
-
client_key "./specs/keys/snakeoil-root.pem"
|
502
|
-
validator_name "chef-validator"
|
503
|
-
validation_key "./specs/keys/snakeoil-validation.pem"
|
504
|
-
encrypted_data_bag_secret "9EE8rGyPB8mXARNrzSDal9TOAQ...e7/x2uPkqMS/tOU="
|
505
|
-
end
|
506
|
-
```
|
507
|
-
|
508
457
|
## Templates and Snippet Scripts
|
509
458
|
|
510
459
|
Templates and snippets use the ERB templating system. When the ERB files are rendered, binding are created to expose ruby the underlying ruby objects.
|
@@ -533,7 +482,6 @@ In addition to the kickstart command generators, the following objects are expos
|
|
533
482
|
Snippets expose the following objects to the template:
|
534
483
|
|
535
484
|
* ```host``` - The current host.
|
536
|
-
* ```chef``` - The chef object.
|
537
485
|
* ```authorized_keys``` - A string containing all the public keys.
|
538
486
|
* ```first_boot_content``` - A string representation of the json content that will make up the first_boot file.
|
539
487
|
* ```nameservers``` - An array of all unique nameservers.
|
data/Rakefile
CHANGED
@@ -13,9 +13,7 @@ namespace :ksvalidator do
|
|
13
13
|
desc 'Set up the validation directories and environment.'
|
14
14
|
task :setup do
|
15
15
|
spath = File.join(File.dirname(__FILE__), 'specs', 'scripts', 'kssetup.sh')
|
16
|
-
|
17
|
-
puts "Setting up in #{vpath}"
|
18
|
-
system("mkdir -p #{vpath} ; cd #{vpath} ; sh #{spath}")
|
16
|
+
system("sh #{spath}")
|
19
17
|
end
|
20
18
|
|
21
19
|
task :clean do
|
data/lib/stork/builder.rb
CHANGED
@@ -27,7 +27,6 @@ module Stork
|
|
27
27
|
|
28
28
|
load_paths = [
|
29
29
|
Configuration[:distros_path],
|
30
|
-
Configuration[:chefs_path],
|
31
30
|
Configuration[:networks_path],
|
32
31
|
Configuration[:layouts_path],
|
33
32
|
Configuration[:hosts_path]
|
@@ -42,7 +41,7 @@ module Stork
|
|
42
41
|
end
|
43
42
|
|
44
43
|
# Expose a limited number of resource methods for DSL parsing from
|
45
|
-
# files. Allow delegation of the host, layout, network,
|
44
|
+
# files. Allow delegation of the host, layout, network, distro,
|
46
45
|
# templates and snippets blocks.
|
47
46
|
#
|
48
47
|
# == Parameters
|
@@ -98,19 +97,6 @@ module Stork
|
|
98
97
|
)
|
99
98
|
end
|
100
99
|
|
101
|
-
# Build and add a chef server to the resource collection.
|
102
|
-
#
|
103
|
-
# == Parameters:
|
104
|
-
# name::
|
105
|
-
# A unique name to identify the chef server.
|
106
|
-
#
|
107
|
-
#
|
108
|
-
def chef(name, &block)
|
109
|
-
@delegated.collection.chefs.add(
|
110
|
-
Resource::Chef.build(name, &block)
|
111
|
-
)
|
112
|
-
end
|
113
|
-
|
114
100
|
# Build and add a distro to the resource collection.
|
115
101
|
#
|
116
102
|
# == Parameters:
|
data/lib/stork/collections.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'stork/collection/base'
|
2
|
-
require 'stork/collection/chefs'
|
3
2
|
require 'stork/collection/distros'
|
4
3
|
require 'stork/collection/hosts'
|
5
4
|
require 'stork/collection/layouts'
|
@@ -13,7 +12,6 @@ module Stork
|
|
13
12
|
attr_reader :hosts
|
14
13
|
attr_reader :layouts
|
15
14
|
attr_reader :networks
|
16
|
-
attr_reader :chefs
|
17
15
|
attr_reader :distros
|
18
16
|
attr_reader :snippets
|
19
17
|
attr_reader :templates
|
@@ -22,7 +20,6 @@ module Stork
|
|
22
20
|
@hosts = Stork::Collection::Hosts.new
|
23
21
|
@layouts = Stork::Collection::Layouts.new
|
24
22
|
@networks = Stork::Collection::Networks.new
|
25
|
-
@chefs = Stork::Collection::Chefs.new
|
26
23
|
@distros = Stork::Collection::Distros.new
|
27
24
|
@snippets = Stork::Collection::Snippets.new
|
28
25
|
@templates = Stork::Collection::Templates.new
|
@@ -31,7 +28,6 @@ module Stork
|
|
31
28
|
alias_method :network, :networks
|
32
29
|
alias_method :layout, :layouts
|
33
30
|
alias_method :host, :hosts
|
34
|
-
alias_method :chef, :chefs
|
35
31
|
alias_method :distro, :distros
|
36
32
|
alias_method :snippet, :snippets
|
37
33
|
alias_method :template, :templates
|
data/lib/stork/configuration.rb
CHANGED
@@ -27,7 +27,6 @@ module Stork
|
|
27
27
|
default(:layouts_path) { relative_to_bundle_path('layouts') }
|
28
28
|
default(:networks_path) { relative_to_bundle_path('networks') }
|
29
29
|
default(:templates_path) { relative_to_bundle_path('templates') }
|
30
|
-
default(:chefs_path) { relative_to_bundle_path('chefs') }
|
31
30
|
default(:distros_path) { relative_to_bundle_path('distros') }
|
32
31
|
default(:public_path) { relative_to_bundle_path('public') }
|
33
32
|
default(:client_name) { 'root' }
|
data/lib/stork/database.rb
CHANGED
@@ -11,20 +11,10 @@ module Stork
|
|
11
11
|
binding
|
12
12
|
end
|
13
13
|
|
14
|
-
def chef
|
15
|
-
host.chef
|
16
|
-
end
|
17
|
-
|
18
14
|
def authorized_keys
|
19
15
|
File.read(Configuration[:authorized_keys_file])
|
20
16
|
end
|
21
17
|
|
22
|
-
def first_boot_content
|
23
|
-
run_list = {}
|
24
|
-
run_list['run_list'] = host.run_list
|
25
|
-
run_list.to_json
|
26
|
-
end
|
27
|
-
|
28
18
|
def nameservers
|
29
19
|
host.interfaces.map { |x| x.nameservers }.uniq.flatten
|
30
20
|
end
|
data/lib/stork/plugin.rb
CHANGED
data/lib/stork/resource/base.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require "ipaddr"
|
2
|
+
|
1
3
|
module Stork
|
2
4
|
module Resource
|
3
5
|
class Base
|
@@ -24,6 +26,29 @@ module Stork
|
|
24
26
|
fail SyntaxError, "#{attr} is required" if send(attr).nil?
|
25
27
|
end
|
26
28
|
|
29
|
+
def require_valid_ips(attr)
|
30
|
+
values = send(attr)
|
31
|
+
values.each do |value|
|
32
|
+
fail SyntaxError, "#{value} is not a valid address" unless is_valid_ip?(value)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def require_valid_ip(attr)
|
37
|
+
value = send(attr)
|
38
|
+
if value
|
39
|
+
fail SyntaxError, "#{value} is not a valid address" unless is_valid_ip?(value)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def is_valid_ip?(ipaddr)
|
44
|
+
begin
|
45
|
+
IPAddr.new ipaddr
|
46
|
+
true
|
47
|
+
rescue IPAddr::InvalidAddressError
|
48
|
+
false
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
27
52
|
def self.build(name = nil, options = {}, &block)
|
28
53
|
inst = new(name, options)
|
29
54
|
klass_name = self.to_s.split('::').last
|
data/lib/stork/resource/host.rb
CHANGED
@@ -3,7 +3,6 @@ module Stork
|
|
3
3
|
class Host < Base
|
4
4
|
attr_accessor :layout
|
5
5
|
attr_accessor :template
|
6
|
-
attr_accessor :chef
|
7
6
|
attr_accessor :pxemac
|
8
7
|
attr_accessor :pre_snippets
|
9
8
|
attr_accessor :post_snippets
|
@@ -14,17 +13,16 @@ module Stork
|
|
14
13
|
attr_accessor :password
|
15
14
|
attr_accessor :selinux
|
16
15
|
attr_accessor :packages
|
17
|
-
attr_accessor :run_list
|
18
|
-
attr_accessor :chef_environment
|
19
16
|
attr_accessor :repos
|
20
17
|
attr_accessor :stork
|
18
|
+
attr_accessor :tags
|
19
|
+
attr_accessor :environments
|
21
20
|
|
22
21
|
def setup
|
23
22
|
@layout = nil
|
24
23
|
@template = nil
|
25
24
|
@distro = nil
|
26
25
|
|
27
|
-
@chef = nil
|
28
26
|
@pxemac = nil
|
29
27
|
@selinux = 'enforcing'
|
30
28
|
@stork = Configuration[:server]
|
@@ -32,10 +30,10 @@ module Stork
|
|
32
30
|
@pre_snippets = Array.new
|
33
31
|
@post_snippets = Array.new
|
34
32
|
@interfaces = Array.new
|
35
|
-
@run_list = Array.new
|
36
|
-
@chef_environment = '_default'
|
37
33
|
@repos = Array.new
|
38
34
|
@packages = default_packages
|
35
|
+
@tags = Array.new
|
36
|
+
@environments = Array.new
|
39
37
|
|
40
38
|
@timezone = Timezone.new("America/Los_Angeles")
|
41
39
|
@firewall = Firewall.new # get from config
|
@@ -47,17 +45,16 @@ module Stork
|
|
47
45
|
'name' => name,
|
48
46
|
'distro' => distro ? distro.name : '',
|
49
47
|
'template' => template ? template.name : '',
|
50
|
-
'chef' => chef ? chef.name : '',
|
51
48
|
'layout' => layout.hashify,
|
52
49
|
'interfaces' => interfaces.map{|i| i.hashify},
|
53
50
|
'pre_snippets' => pre_snippets.map{|s| s.name},
|
54
51
|
'post_snippets' => post_snippets.map{|s| s.name},
|
55
52
|
'repos' => repos.map{|r| r.name},
|
56
|
-
'run_list' => run_list,
|
57
|
-
'chef_environment' => chef_environment,
|
58
53
|
'packages' => packages,
|
59
54
|
'timezone' => timezone.zone,
|
60
|
-
'selinux' => selinux
|
55
|
+
'selinux' => selinux,
|
56
|
+
'tags' => tags,
|
57
|
+
'environments' => environments
|
61
58
|
}
|
62
59
|
end
|
63
60
|
|
@@ -112,14 +109,6 @@ module Stork
|
|
112
109
|
delegated.template = template
|
113
110
|
end
|
114
111
|
|
115
|
-
def chef(value, &block)
|
116
|
-
if block_given?
|
117
|
-
delegated.chef = Chef.build(value, &block)
|
118
|
-
else
|
119
|
-
delegated.chef = collection.chefs.get(value)
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
112
|
def pxemac(value)
|
124
113
|
delegated.pxemac = value
|
125
114
|
end
|
@@ -174,19 +163,6 @@ module Stork
|
|
174
163
|
delegated.selinux = value.to_s
|
175
164
|
end
|
176
165
|
|
177
|
-
def run_list(value)
|
178
|
-
if value.is_a?(String)
|
179
|
-
list = value.split(',')
|
180
|
-
else
|
181
|
-
list = value
|
182
|
-
end
|
183
|
-
delegated.run_list |= list
|
184
|
-
end
|
185
|
-
|
186
|
-
def chef_environment(value)
|
187
|
-
delegated.chef_environment = value
|
188
|
-
end
|
189
|
-
|
190
166
|
def repo(name, args = {})
|
191
167
|
delegated.repos << Repo.build(name, args)
|
192
168
|
end
|
@@ -194,6 +170,14 @@ module Stork
|
|
194
170
|
def package(name)
|
195
171
|
delegated.packages << name
|
196
172
|
end
|
173
|
+
|
174
|
+
def tags(tag)
|
175
|
+
delegated.tags << tag
|
176
|
+
end
|
177
|
+
|
178
|
+
def environments(name)
|
179
|
+
delegated.environments << name
|
180
|
+
end
|
197
181
|
end
|
198
182
|
|
199
183
|
alias_method :id, :name
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require "ipaddr"
|
2
|
+
|
1
3
|
module Stork
|
2
4
|
module Resource
|
3
5
|
class Network < Base
|
@@ -13,7 +15,17 @@ module Stork
|
|
13
15
|
@search_paths = Array.new
|
14
16
|
end
|
15
17
|
|
18
|
+
def validate!
|
19
|
+
require_valid_ips :nameservers
|
20
|
+
require_valid_ip :gateway
|
21
|
+
require_valid_ip :netmask
|
22
|
+
end
|
23
|
+
|
16
24
|
class NetworkDelegator < Stork::Resource::Delegator
|
25
|
+
def network(network)
|
26
|
+
delegated.network = network
|
27
|
+
end
|
28
|
+
|
17
29
|
def netmask(netmask)
|
18
30
|
delegated.netmask = netmask
|
19
31
|
end
|