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.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -1
  3. data/.travis.yml +6 -6
  4. data/README.md +1 -53
  5. data/Rakefile +1 -3
  6. data/lib/stork/builder.rb +1 -15
  7. data/lib/stork/client/plugins/host_show.rb +0 -2
  8. data/lib/stork/collections.rb +0 -4
  9. data/lib/stork/configuration.rb +0 -1
  10. data/lib/stork/database.rb +1 -1
  11. data/lib/stork/deploy/snippet_binding.rb +0 -10
  12. data/lib/stork/plugin.rb +1 -1
  13. data/lib/stork/resource/base.rb +25 -0
  14. data/lib/stork/resource/host.rb +15 -31
  15. data/lib/stork/resource/interface.rb +1 -1
  16. data/lib/stork/resource/network.rb +12 -0
  17. data/lib/stork/resources.rb +0 -1
  18. data/lib/stork/version.rb +1 -1
  19. data/specs/builder_spec.rb +0 -1
  20. data/specs/collections_spec.rb +0 -4
  21. data/specs/kickstart_spec.rb +2 -3
  22. data/specs/resource_host_spec.rb +19 -27
  23. data/specs/resource_interface_spec.rb +22 -1
  24. data/specs/resource_layout_spec.rb +3 -3
  25. data/specs/resource_network_spec.rb +56 -0
  26. data/specs/scripts/kssetup.sh +13 -21
  27. data/specs/scripts/ksvalidate.sh +9 -14
  28. data/specs/scripts/requirements.txt +8 -0
  29. data/specs/server_spec.rb +2 -2
  30. data/specs/stork/bundles/hosts/example.org.rb +5 -16
  31. data/specs/stork/bundles/networks/internal-one.rb +7 -0
  32. data/specs/stork/bundles/networks/internal-two.rb +3 -0
  33. metadata +41 -52
  34. data/.ruby-gemset +0 -1
  35. data/box/Vagrantfile +0 -41
  36. data/box/bootstrap.sh +0 -317
  37. data/box/integration.sh +0 -33
  38. data/lib/stork/collection/chefs.rb +0 -6
  39. data/lib/stork/resource/chef.rb +0 -81
  40. data/specs/deploy_snippet_binding_spec.rb +0 -15
  41. data/specs/resource_chef_spec.rb +0 -122
  42. data/specs/stork/bundles/chefs/default.rb +0 -9
  43. data/specs/stork/bundles/networks/local.rb +0 -6
  44. data/specs/stork/bundles/networks/org.rb +0 -7
  45. data/specs/stork/bundles/snippets/chef-bootstrap.erb +0 -104
  46. 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: c25720b623362f9066503a5134f8e43bd657d55e
4
- data.tar.gz: 6ef866902b3736eec018d0fef07ee4fe221a3d36
3
+ metadata.gz: eb70dddbdd8452f89e72c5430a152525ffde4a8d
4
+ data.tar.gz: 9f4ea640d74fb77973d86abee6c564067a1433f2
5
5
  SHA512:
6
- metadata.gz: 728bc4a4d5b8f6f3c7bf139d4fd7ca7678f98aa73b15388d55b851f8e0e9bcb5bb32f8a75626b20ab1a2b2a5c5b074537cbd024b1a20da8008b4a9d011bf0ebb
7
- data.tar.gz: 78f163a2fa584dac08c8581ebfa8ad0464a92332618392704e1ae91b1ef3742b5fb5319721b83907b5c70e38eeade5545251e710cb8e86f1876172915bc069f9
6
+ metadata.gz: 11a458fd20ac0204fcaba0fc150495321023017411123ca7acc5d11c2ea7e4f88609db88a98fae780f0823d0a7a0c3dd56a2acb4eac1ca1c676bcfcab87de73f
7
+ data.tar.gz: 1b84d3ebeb8cfc2f3f5aa5e960830717b053f107facbf51fdecad700da0b76b3fa29daf20409ae52c8bc1ee347a5b34171e3a0e113dd6c36d0fb9c2c9225c2e7
@@ -1 +1 @@
1
- 2.0.0
1
+ 2.4.4
@@ -1,10 +1,10 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.1.1
4
- - 2.0.0
5
- - 1.9.3
3
+ - 2.4.0
6
4
 
7
- before_script: bundle exec rake ksvalidator:setup
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
  [![Build Status](https://travis-ci.org/rlyon/stork.png?branch=master)](https://travis-ci.org/rlyon/stork)
3
3
  [![Coverage Status](https://coveralls.io/repos/rlyon/stork/badge.png)](https://coveralls.io/r/rlyon/stork)
4
4
  [![Code Climate](https://codeclimate.com/github/rlyon/stork.png)](https://codeclimate.com/github/rlyon/stork)
5
+ [![Gem Version](http://img.shields.io/gem/v/stork.svg)](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
- vpath = File.join(File.dirname(__FILE__), 'specs')
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
@@ -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, chef, distro,
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:
@@ -9,8 +9,6 @@ module HostShowPlugin
9
9
  show('name', data)
10
10
  show('distro', data)
11
11
  show('template', data)
12
- show('chef', data)
13
- show('run_list', data)
14
12
  show('pre_snippets', data)
15
13
  show('post_snippets', data)
16
14
  show('packages', data)
@@ -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
@@ -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' }
@@ -3,7 +3,7 @@ require 'sqlite3'
3
3
  module Stork
4
4
  class Database
5
5
  def initialize(dbpath)
6
- unless Dir.exists?(dbpath)
6
+ unless Dir.exist?(dbpath)
7
7
  FileUtils.mkdir_p(dbpath)
8
8
  end
9
9
 
@@ -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
@@ -40,7 +40,7 @@ module Stork
40
40
 
41
41
  def fetch(path)
42
42
  response = RestClient.get "#{@stork}/api/v1/#{path}"
43
- data = JSON.parse(response)
43
+ JSON.parse(response)
44
44
  end
45
45
 
46
46
  def print(first, second, options = {})
@@ -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
@@ -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
@@ -25,7 +25,7 @@ module Stork
25
25
  end
26
26
 
27
27
  def validate!
28
-
28
+ require_valid_ip :ip
29
29
  end
30
30
 
31
31
  def netmask
@@ -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