elevage 0.1.0 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -1
  3. data/README.md +33 -11
  4. data/elevage.gemspec +15 -15
  5. data/features/archive +3 -22
  6. data/features/build.feature +2 -1
  7. data/features/generate.feature +3 -9
  8. data/features/health_env_failure.feature +2 -8
  9. data/features/health_failure.feature +1 -2
  10. data/features/health_success.feature +3 -9
  11. data/features/list.feature +3 -9
  12. data/features/step_definitions/elevage_steps.rb +2 -2
  13. data/lib/elevage/build.rb +4 -1
  14. data/lib/elevage/constants.rb +2 -2
  15. data/lib/elevage/environment.rb +66 -39
  16. data/lib/elevage/generate.rb +4 -3
  17. data/lib/elevage/health.rb +4 -0
  18. data/lib/elevage/new.rb +4 -2
  19. data/lib/elevage/platform.rb +11 -3
  20. data/lib/elevage/provisioner.rb +61 -21
  21. data/lib/elevage/provisionerrunqueue.rb +25 -10
  22. data/lib/elevage/templates/vcenter.yml.tt +7 -12
  23. data/lib/elevage/version.rb +1 -1
  24. data/lib/elevage.rb +5 -0
  25. metadata +58 -88
  26. data/.ruby-version +0 -1
  27. data/.yardoc/checksums +0 -12
  28. data/.yardoc/object_types +0 -0
  29. data/.yardoc/objects/root.dat +0 -0
  30. data/.yardoc/proxy_types +0 -0
  31. data/doc/Elevage/Build.html +0 -435
  32. data/doc/Elevage/CLI.html +0 -282
  33. data/doc/Elevage/Environment.html +0 -950
  34. data/doc/Elevage/Generate.html +0 -346
  35. data/doc/Elevage/Health.html +0 -359
  36. data/doc/Elevage/New.html +0 -411
  37. data/doc/Elevage/Platform.html +0 -1119
  38. data/doc/Elevage/Provisioner.html +0 -804
  39. data/doc/Elevage/ProvisionerRunQueue.html +0 -765
  40. data/doc/Elevage/Runner.html +0 -319
  41. data/doc/Elevage.html +0 -501
  42. data/doc/_index.html +0 -239
  43. data/doc/class_list.html +0 -58
  44. data/doc/css/common.css +0 -1
  45. data/doc/css/full_list.css +0 -57
  46. data/doc/css/style.css +0 -339
  47. data/doc/file.README.html +0 -187
  48. data/doc/file_list.html +0 -60
  49. data/doc/frames.html +0 -26
  50. data/doc/index.html +0 -187
  51. data/doc/js/app.js +0 -219
  52. data/doc/js/full_list.js +0 -181
  53. data/doc/js/jquery.js +0 -4
  54. data/doc/method_list.html +0 -369
  55. data/doc/top-level-namespace.html +0 -112
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 26d8f1dce1b2c33c9dafbfab62a0c61022542c75
4
- data.tar.gz: 9007db613e819ce05d89eb91e2dfd2d41ffc71ed
3
+ metadata.gz: 831308271c5d157f33c0c90509d9368ed88652aa
4
+ data.tar.gz: 87a2972d4ad9e580b8d2d0dfff92a78f8cf28adb
5
5
  SHA512:
6
- metadata.gz: 188b981a5844e3ea05e192e5e2f97bc80ec52fafc2fd958f7557ece1218b888d546999bb1e3a1e456ab5f8c55df08241d7f176b8e6aaacd109bd8f251c5b10ee
7
- data.tar.gz: 621bf4c7b7e2cf2bbc30c86538adf130e5a735e55b50fabec589d9fa500d5fbcacb64a21e41b891944dbff67b803117bff6abe22ae23fc0d7e910896dec986e4
6
+ metadata.gz: 68f1b3bcd8ca570402fbb44c0e1d289c65693fc59fd51205625cfe0f58b47f674c53f6faf611f969eda99cd3992b219021e61e4c57d4a4e7d80b49e4316d85e3
7
+ data.tar.gz: 868903fced4812feec7cc8e43616c7b9e8d375ab5d7fac49d0a3f1c92c3fa40aa72adaed926dbe9c09ce0729be5d05d7ccb84b9e180c8c89fc6290935f3ebc74
data/.gitignore CHANGED
@@ -18,4 +18,6 @@ tmp/
18
18
  .*sw[p-z]
19
19
  .ruby-version
20
20
  coverage/.last_run.json
21
- coverage/.resultset.json
21
+ coverage/.resultset.json
22
+ .yardoc/
23
+ doc/
data/README.md CHANGED
@@ -1,14 +1,35 @@
1
1
  # Elevage
2
2
 
3
- [![Build Status](https://travis-ci.org/ActiveSCM/elevage.svg?branch=master)][travis]
4
- [![Dependency Status](https://gemnasium.com/ActiveSCM/elevage.png?travis)][gemnasium]
5
- [![Coverage Status](https://coveralls.io/repos/ActiveSCM/elevage/badge.png?branch=master)][coveralls]
6
- [![Inline docs](http://inch-ci.org/github/ActiveSCM/elevage.png?branch=master)][inch]
3
+ [![Build Status](https://travis-ci.org/activenetwork-automation/elevage.svg?branch=master)][travis]
4
+ [![Dependency Status](https://gemnasium.com/activenetwork-automation/elevage.png?travis)][gemnasium]
5
+ [![Coverage Status](https://coveralls.io/repos/activenetwork-automation/elevage/badge.png?branch=master)][coveralls]
6
+ [![Inline docs](http://inch-ci.org/github/activenetwork-automation/elevage.png?branch=master)][inch]
7
7
 
8
- [travis]: http://travis-ci.org/ActiveSCM/elevage
9
- [gemnasium]: https://gemnasium.com/ActiveSCM/elevage
10
- [coveralls]: https://coveralls.io/r/ActiveSCM/elevage
11
- [inch]: http://inch-ci.org/github/ActiveSCM/elevage
8
+ [travis]: http://travis-ci.org/activenetwork-automation/elevage
9
+ [gemnasium]: https://gemnasium.com/activenetwork-automation/elevage
10
+ [coveralls]: https://coveralls.io/r/activenetwork-automation/elevage
11
+ [inch]: http://inch-ci.org/github/activenetwork-automation/elevage
12
+
13
+ `elevage` is a command-line tool that allows you to define an application
14
+ platform in a set of plain-text (YAML) configuration files and use those
15
+ definitions to provision the virtual machines on which the application will
16
+ live. The virtual machine will also be converged with the Chef runlists as
17
+ defined your configuration files.
18
+
19
+ Currently, `elevage` relies upon Chef's `knife` command and the `knife-vsphere`
20
+ plugin, and has been tested with various releases of Chef 11 and 12 as well
21
+ as the ChefDK.
22
+
23
+ #### External Dependencies
24
+
25
+ You must have the `knife` command installed on your path, and the
26
+ `knife-vsphere` plugin installed. Your options are to:
27
+
28
+ - Install [Chef Client](https://www.chef.io/download-chef-client/) and then
29
+ install `knife-vsphere` via Chef's embedded ruby's `gem`
30
+ - Install [ChefDK](https://downloads.chef.io/chef-dk/) and then
31
+ `chef gem install knife-vsphere`
32
+ - Install Chef via rubygems with `gem install chef knife-vsphere`
12
33
 
13
34
  #### Installation
14
35
 
@@ -86,14 +107,15 @@ Options:
86
107
 
87
108
  ## Contributing
88
109
 
89
- 1. Fork it ( https://github.com/ActiveSCM/elevage/fork )
110
+ 1. Fork it ( https://github.com/activenetwork-automation/elevage/fork )
90
111
  2. Create your feature branch (`git checkout -b my-new-feature`)
91
112
  3. Commit your changes (`git commit -am 'Add some feature'`)
92
113
  4. Push to the branch (`git push origin my-new-feature`)
93
114
  5. Create a new Pull Request
94
115
 
95
116
  ### License and Authors
96
- - Authors:: Nic Cheneweth (<nic.cheneweth@activenetwork.com>), (Gregory Ruiz-Ade <gregory.ruiz-ade@activenetwork.com>)
117
+ - [Nic Cheneweth](https://github.com/Cheneweth)
118
+ - [Gregory Ruiz-Ade](https://github.com/gkra)
97
119
 
98
120
  ```
99
121
  Copyright 2014 Active Network, LLC
@@ -109,4 +131,4 @@ distributed under the License is distributed on an "AS IS" BASIS,
109
131
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
110
132
  See the License for the specific language governing permissions and
111
133
  limitations under the License.
112
- ```
134
+ ```
data/elevage.gemspec CHANGED
@@ -19,21 +19,21 @@ Gem::Specification.new do |spec|
19
19
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
20
  spec.require_paths = ['lib']
21
21
 
22
- spec.add_development_dependency 'bundler', '~> 1.6'
23
- spec.add_development_dependency('rake')
22
+ spec.add_development_dependency('bundler', '~> 1.6')
23
+ spec.add_development_dependency('rake', '~> 10.4.2')
24
24
  spec.add_development_dependency('yard')
25
- spec.add_development_dependency('aruba')
26
- spec.add_development_dependency('cucumber')
27
- spec.add_development_dependency('psych')
28
- spec.add_development_dependency('rspec')
29
- spec.add_development_dependency('guard')
30
- spec.add_development_dependency('guard-rubocop')
31
- spec.add_development_dependency('growl')
32
- spec.add_development_dependency('coveralls')
33
- spec.add_development_dependency('chef')
34
- spec.add_development_dependency('knife-vsphere')
35
- spec.add_dependency('thor')
36
- spec.add_dependency('open4')
37
- spec.add_dependency('english')
25
+ spec.add_development_dependency('aruba', '~> 0.6.2')
26
+ spec.add_development_dependency('cucumber', '~>2.0.0')
27
+ spec.add_development_dependency('psych', '= 2.0.5')
28
+ spec.add_development_dependency('rspec', '~> 3.3.0')
29
+ spec.add_development_dependency('guard', '~> 2.12.6')
30
+ spec.add_development_dependency('guard-rubocop', '~> 1.2.0')
31
+ spec.add_development_dependency('growl', '~> 1.0.3')
32
+ spec.add_development_dependency('coveralls', '~> 0.8.1')
33
+ spec.add_development_dependency('chef', '~> 12.3.0')
34
+ spec.add_development_dependency('knife-vsphere', '~> 1.0.1')
35
+ spec.add_dependency('thor', '~> 0.19.1')
36
+ spec.add_dependency('open4', '~> 1.3.4')
37
+ spec.add_dependency('english', '~> 0.6.3')
38
38
  end
39
39
  # rubocop:enable all
data/features/archive CHANGED
@@ -84,13 +84,7 @@
84
84
  resourcepool: 'App-Web Linux/Corporate - o4'
85
85
  appendenv: true
86
86
  appenddomain: true
87
- datastores:
88
- - NonProd_Cor_PlaSer_25_111
89
- - NonProd_Cor_PlaSer_26_111
90
- - NonProd_Cor_PlaSer_38_111
91
- - NonProd_Cor_PlaSer_39_111
92
- - NonProd_Cor_PlaSer_40_111
93
- - NonProd_Cor_PlaSer_41_111
87
+ datastore: 'NonProd_Cor_PlaSer'
94
88
 
95
89
  domain: dev.activenetwork.com
96
90
  dnsips:
@@ -101,20 +95,7 @@
101
95
  <<: *vcenter
102
96
 
103
97
  datacenter: 'WCDC Prod'
104
- datastores:
105
- - Prod_Cor_PlaSer_03_237
106
- - Prod_Cor_PlaSer_04_237
107
- - Prod_Cor_PlaSer_06F9_473
108
- - Prod_Cor_PlaSer_06F9_473
109
- - Prod_Cor_PlaSer_080D_473
110
- - Prod_Cor_PlaSer_0812_473
111
- - Prod_Cor_PlaSer_08E0_473
112
- - Prod_Cor_PlaSer_08EA_473
113
- - Prod_Cor_PlaSer_08F4_473
114
- - Prod_Cor_PlaSer_0B89_473
115
- - Prod_Cor_PlaSer_0B93_473
116
- - Prod_Cor_PlaSer_847_473
117
- - Prod_Cor_PlaSer_851_473
98
+ datastore: 'Prod_Cor_PlaSer'
118
99
 
119
100
  domain: active.tan
120
101
  dnsips:
@@ -311,4 +292,4 @@
311
292
  - 10.219.161.78
312
293
  """
313
294
  When I run `elevage guard full`
314
- Then the exit status should be 0
295
+ Then the exit status should be 0
@@ -84,6 +84,7 @@ Feature: Provisioning platform vm's
84
84
  resourcepool: 'App-Web Linux/Corporate'
85
85
  appendenv: true
86
86
  appenddomain: true
87
+ appendtier: true
87
88
  datastores:
88
89
  - NonProd_Cor_25
89
90
  - NonProd_Cor_26
@@ -232,6 +233,6 @@ Feature: Provisioning platform vm's
232
233
  And the file "logs/qa-mq-01w.log" should contain:
233
234
  """
234
235
  qa-mq-01w: Provisioning.
235
- knife vsphere vm clone --vsinsecure --start --vsuser svc_provisioner --vspass changeme --vshost www.google.com --folder Corporate/Platform Services/Templates --template centos32g-6.5-x86_64-20140714 --vsdc WCDC NonProd --dest-folder Corporate/Platform Services/app/qa --resource-pool App-Web Linux/Corporate --datastore NonProd_Cor_25 --ccpu 2 --cram 12 --cvlan DEV_APP_NET --cips 10.10.161.121/20 --cdnsips 10.10.10.5,10.10.10.6 --cgw 10.10.160.1 --chostname qa-mq-01w --ctz 085 --cdomain app.dev.corp.local --cdnssuffix app.dev.corp.local --bootstrap --template-file chef-full.erb --fqdn 10.10.161.121 --ssh-user knife --identity-file knife_rsa --node-name qa-mq-01w.qa.app.dev.corp.local --run-list role[loc_uswest],role[base],role[mq] --environment qa --bootstrap-version 11.4.0 qa-mq-01w.qa.app.dev.corp.local
236
+ knife vsphere vm clone --vsinsecure --start --vsuser svc_provisioner --vspass changeme --vshost www.google.com --folder Corporate/Platform Services/Templates --template centos32g-6.5-x86_64-20140714 --vsdc WCDC NonProd --dest-folder Corporate/Platform Services/app/qa/App --resource-pool App-Web Linux/Corporate --datastore --ccpu 2 --cram 12 --cvlan DEV_APP_NET --cips 10.10.161.121/20 --cdnsips 10.10.10.5,10.10.10.6 --cgw 10.10.160.1 --chostname qa-mq-01w --ctz 085 --cdomain app.dev.corp.local --cdnssuffix app.dev.corp.local --bootstrap --template-file chef-full.erb --fqdn 10.10.161.121 --ssh-user knife --identity-file knife_rsa --node-name qa-mq-01w.app.dev.corp.local --run-list role[loc_uswest],role[base],role[mq] --environment qa --bootstrap-version 11.4.0 qa-mq-01w.app.dev.corp.local
236
237
  qa-mq-01w: exit status: 0
237
238
  """
@@ -83,11 +83,7 @@ Feature: GENERATE new environment yml file
83
83
  resourcepool: 'App-Web Linux/Corporate'
84
84
  appendenv: true
85
85
  appenddomain: true
86
- datastores:
87
- - NonProd_Cor_25
88
- - NonProd_Cor_26
89
- - NonProd_Cor_38
90
- - NonProd_Cor_39
86
+ datastore: 'NonProd_Cor'
91
87
 
92
88
  domain: dev.corp.local
93
89
  dnsips:
@@ -98,9 +94,7 @@ Feature: GENERATE new environment yml file
98
94
  <<: *vcenter
99
95
 
100
96
  datacenter: 'WCDC Prod'
101
- datastores:
102
- - Prod_Cor_03
103
- - Prod_Cor_04
97
+ datastore: 'Prod_Cor'
104
98
 
105
99
  domain: corp.local
106
100
  dnsips:
@@ -232,4 +226,4 @@ Feature: GENERATE new environment yml file
232
226
  -
233
227
 
234
228
 
235
- """
229
+ """
@@ -84,11 +84,7 @@ Feature: HEALTH check of erroneous environment-only definition file items
84
84
  resourcepool: 'App-Web Linux/Corporate'
85
85
  appendenv: true
86
86
  appenddomain: true
87
- datastores:
88
- - NonProd_Cor_25
89
- - NonProd_Cor_26
90
- - NonProd_Cor_38
91
- - NonProd_Cor_39
87
+ datastore: 'NonProd_Cor'
92
88
 
93
89
  domain: dev.corp.local
94
90
  dnsips:
@@ -99,9 +95,7 @@ Feature: HEALTH check of erroneous environment-only definition file items
99
95
  <<: *vcenter
100
96
 
101
97
  datacenter: 'WCDC Prod'
102
- datastores:
103
- - Prod_Cor_03
104
- - Prod_Cor_04
98
+ datastore: 'Prod_Cor'
105
99
 
106
100
  domain: corp.local
107
101
  dnsips:
@@ -89,8 +89,7 @@ Feature: HEALTH check of erroneous platform definition file items
89
89
  resourcepool:
90
90
  appendenv: incorrect
91
91
  appenddomain:
92
- datastores:
93
- -
92
+ datastore:
94
93
 
95
94
  domain:
96
95
  dnsips:
@@ -83,11 +83,7 @@ Feature: HEALTH check of correct platform definition file items
83
83
  resourcepool: 'App-Web Linux/Corporate'
84
84
  appendenv: true
85
85
  appenddomain: true
86
- datastores:
87
- - NonProd_Cor_25
88
- - NonProd_Cor_26
89
- - NonProd_Cor_38
90
- - NonProd_Cor_39
86
+ datastore: 'NonProd_Cor'
91
87
 
92
88
  domain: dev.corp.local
93
89
  dnsips:
@@ -98,9 +94,7 @@ Feature: HEALTH check of correct platform definition file items
98
94
  <<: *vcenter
99
95
 
100
96
  datacenter: 'WCDC Prod'
101
- datastores:
102
- - Prod_Cor_03
103
- - Prod_Cor_04
97
+ datastore: 'Prod_Cor'
104
98
 
105
99
  domain: corp.local
106
100
  dnsips:
@@ -276,4 +270,4 @@ Feature: HEALTH check of correct platform definition file items
276
270
  When I run `elevage health`
277
271
  Then the exit status should be 0
278
272
  And the output should contain "All base platform desired state files created and syntactically correct"
279
- And the output should contain "specific definition yml syntactically correct"
273
+ And the output should contain "specific definition yml syntactically correct"
@@ -83,11 +83,7 @@ Feature: LIST platform definition file items
83
83
  resourcepool: 'App-Web Linux/Corporate'
84
84
  appendenv: true
85
85
  appenddomain: true
86
- datastores:
87
- - NonProd_Cor_25
88
- - NonProd_Cor_26
89
- - NonProd_Cor_38
90
- - NonProd_Cor_39
86
+ datastore: 'NonProd_Cor'
91
87
 
92
88
  domain: dev.corp.local
93
89
  dnsips:
@@ -98,9 +94,7 @@ Feature: LIST platform definition file items
98
94
  <<: *vcenter
99
95
 
100
96
  datacenter: 'WCDC Prod'
101
- datastores:
102
- - Prod_Cor_03
103
- - Prod_Cor_04
97
+ datastore: 'Prod_Cor'
104
98
 
105
99
  domain: corp.local
106
100
  dnsips:
@@ -312,4 +306,4 @@ Feature: LIST platform definition file items
312
306
 
313
307
  When I run `elevage list random`
314
308
  Then the exit status should be 1
315
- And the output should contain "unknown LIST command"
309
+ And the output should contain "unknown LIST command"
@@ -1,4 +1,4 @@
1
- # rubocop:disable LineLength, StringLiterals
1
+ # rubocop:disable LineLength
2
2
  When(/^I get general help for "([^"]*)"$/) do |app_name|
3
3
  @app_name = app_name
4
4
  step %(I run `#{app_name} --help`)
@@ -24,4 +24,4 @@ end
24
24
  Then(/^the output should display the version$/) do
25
25
  step %(the output should match /\\d+\\.\\d+\\.\\d+/)
26
26
  end
27
- # rubocop:enable LineLength, StringLiterals
27
+ # rubocop:enable LineLength
data/lib/elevage/build.rb CHANGED
@@ -1,7 +1,8 @@
1
1
  require 'thor/group'
2
2
 
3
3
  module Elevage
4
- # Create new platform definition files and environments folder structure
4
+ # Create new platform definition files and environments folder structure,
5
+ # used by the command line `build` option
5
6
  class Build < Thor::Group
6
7
  include Thor::Actions
7
8
 
@@ -35,6 +36,8 @@ module Elevage
35
36
  end
36
37
 
37
38
  # rubocop:disable MethodLength, LineLength, CyclomaticComplexity, PerceivedComplexity
39
+
40
+ # Process and execute the `build` command
38
41
  def build
39
42
  # Make the logfile directory if it doesn't exist
40
43
  Dir.mkdir(options[:logfiles]) unless Dir.exist?(options[:logfiles])
@@ -1,4 +1,4 @@
1
- # rubocop:disable LineLength, StringLiterals
1
+ # rubocop:disable LineLength
2
2
  module Elevage
3
3
  # options description messages
4
4
  # DESC_followed by command and the description
@@ -110,4 +110,4 @@ module Elevage
110
110
  fail_health_check: 'elevage: health check revealed errors'
111
111
  }
112
112
  end
113
- # rubocop:enable LineLength, StringLiterals
113
+ # rubocop:enable LineLength
@@ -5,8 +5,10 @@ require_relative 'constants'
5
5
  require_relative 'platform'
6
6
  require_relative 'provisioner'
7
7
 
8
- # rubocop:disable ClassLength
8
+ # Refer to README.md for use instructions
9
9
  module Elevage
10
+ # rubocop:disable ClassLength
11
+
10
12
  # Environment class
11
13
  class Environment
12
14
  attr_accessor :name
@@ -15,6 +17,10 @@ module Elevage
15
17
  attr_accessor :nodenameconvention
16
18
 
17
19
  # rubocop:disable LineLength
20
+
21
+ # Construct a new environment object.
22
+ # @param [String] env Name of the environment to construct
23
+ # @return [Elevage::Environment]
18
24
  def initialize(env)
19
25
  # Confirm environment has been defined in the platform
20
26
  platform = Elevage::Platform.new
@@ -32,8 +38,9 @@ module Elevage
32
38
  end
33
39
  # rubocop:enable LineLength
34
40
 
35
- # Public: Environment class method
41
+ # List the nodes for this environment.
36
42
  # Returns multiline string = IP, fqdn, runlist
43
+ # @return [String] Expanded node list
37
44
  def list_nodes
38
45
  nodes = @vcenter['destfolder'].to_s + "\n"
39
46
  @components.each do |component, _config|
@@ -47,6 +54,9 @@ module Elevage
47
54
  end
48
55
 
49
56
  # rubocop:disable MethodLength, LineLength, CyclomaticComplexity, PerceivedComplexity
57
+
58
+ # Is the environment healthy?
59
+ # @return [Boolean] Health status of the environment
50
60
  def healthy?
51
61
  platform = Elevage::Platform.new
52
62
  health = ''
@@ -78,7 +88,8 @@ module Elevage
78
88
  end
79
89
  # rubocop:enable MethodLength, LineLength, CyclomaticComplexity, PerceivedComplexity
80
90
 
81
- # Public: basic class puts string output
91
+ # Override to string-ify the environment
92
+ # @return [String]
82
93
  def to_s
83
94
  puts @name
84
95
  puts @vcenter.to_yaml
@@ -86,10 +97,16 @@ module Elevage
86
97
  puts @nodenameconvention.to_yaml
87
98
  end
88
99
 
100
+ # rubocop:disable MethodLength, LineLength, CyclomaticComplexity, PerceivedComplexity
101
+
89
102
  # Public: method to request provisioning of all or a portion
90
103
  # of the environment
91
- # rubocop:disable MethodLength, LineLength, CyclomaticComplexity, PerceivedComplexity
92
- def provision(type: all, tier: nil, component: nil, instance: nil, options: nil)
104
+ # @param [String] type What type of provisioning, `:all`, `:tier`, `:component`, or `:node`
105
+ # @param [String] tier Name of the environment tier, when `type` is `:tier`
106
+ # @param [String] component Name of component to provision, when `type` is `:component` or `:node`
107
+ # @param [String] instance Numerical instance of the `component`, when `type` is `:node` (i.e., 1, 2, 3)
108
+ # @param [String] options Thor-provided `options` hash
109
+ def provision(type: :all, tier: nil, component: nil, instance: nil, options: nil)
93
110
  # Create the ProvisionerRunQueue to batch up our tasks
94
111
  runner = ProvisionerRunQueue.new
95
112
 
@@ -102,19 +119,15 @@ module Elevage
102
119
  end
103
120
 
104
121
  @components.each do |component_name, component_data|
105
- next unless type.eql?(:all) || component_data['tier'].match(/#{tier}/i) && component_name.match(/#{component}/i)
122
+ next unless type.eql?(:all) || component_data['tier'].match(/\A#{tier.to_s}\z/i) || component_name.match(/\A#{component.to_s}\z/i)
106
123
 
107
124
  1.upto(component_data['addresses'].count) do |component_instance|
108
125
  next unless instance == component_instance || instance.nil?
109
-
110
126
  instance_name = node_name(component_name, component_instance)
111
-
112
127
  # Create the Provisioner
113
128
  provisioner = Elevage::Provisioner.new(instance_name, component_data, component_instance, self, options)
114
-
115
129
  # Add it to the queue
116
130
  runner.provisioners << provisioner
117
-
118
131
  end
119
132
  end
120
133
 
@@ -127,18 +140,18 @@ module Elevage
127
140
 
128
141
  private
129
142
 
130
- # Private: updates env hash with necessary info from Platform files.
143
+ # rubocop:disable MethodLength, LineLength, CyclomaticComplexity, PerceivedComplexity
144
+
145
+ # Updates env hash with necessary info from Platform files.
131
146
  # This is a blend of env and Platform info needed to construct
132
147
  # Environment class object
133
148
  #
134
- # Params
135
- # env: string passed from commend line, simple environment name
136
- # env_yaml: hash from requested environment.yml
137
- # platform: Platform class object built from standard
138
- # platform definition files
139
- #
140
- # Returns Hash: updated env_yaml hash
141
- # rubocop:disable MethodLength, LineLength
149
+ # @param [String] env String passed from commend line, simple environment
150
+ # name
151
+ # @param [Hash] env_yaml Hash from requested environment.yml
152
+ # @param [Elevage::Platform] platform Platform class object built from
153
+ # standard platform definition files
154
+ # @return [Hash] Updated env_yaml hash
142
155
  def build_env(env, env_yaml, platform)
143
156
  # substitute vcenter resources from vcenter.yml for location defined in environment file
144
157
  env_yaml['vcenter'] = platform.vcenter[env_yaml['vcenter']]
@@ -150,7 +163,12 @@ module Elevage
150
163
  # component info. The Build command will run error checking before building, but to support
151
164
  # the debugging value of the list command only hash.merge! is performed at this point.
152
165
  platform.components.each do |component, _config|
153
- env_yaml['components'][component].merge!(platform.components[component]) { |_key, v1, _v2| v1 } unless env_yaml['components'][component].nil?
166
+ begin
167
+ env_yaml['components'][component].merge!(platform.components[component]) { |_key, v1, _v2| v1 } unless env_yaml['components'][component].nil?
168
+ rescue => error
169
+ puts "ERROR: build_env: could not merge component \"#{component}\" for environment \"#{env}\"!"
170
+ raise error
171
+ end
154
172
  end
155
173
  # substitute network and components for specified values from platform definition files
156
174
  env_yaml['components'].each do |component, _config|
@@ -163,21 +181,28 @@ module Elevage
163
181
  unless env_yaml['vcenter'].nil?
164
182
  # append env name to destination folder if appendenv == true
165
183
  env_yaml['vcenter']['destfolder'] += (env_yaml['vcenter']['appendenv'] ? '/' + env.to_s : '')
184
+
166
185
  # prepend app name to domain if appenddomain == true
167
- env_yaml['vcenter']['appenddomain'] ? env_yaml['vcenter']['domain'] = '.' + platform.name + '.' + env_yaml['vcenter']['domain'] : ''
186
+ # If 'appenddomain' is true, add the environment name as a subdomain.
187
+ if env_yaml['vcenter']['appenddomain']
188
+ env_yaml['vcenter']['domain'] = '.' + platform.name + '.' + env_yaml['vcenter']['domain']
189
+ end
190
+
191
+ # Make sure the domain has a leading '.' or things don't look right.
192
+ env_yaml['vcenter']['domain'].sub!(/^/, '.') unless env_yaml['vcenter']['domain'].match(/^\./)
193
+
168
194
  end
169
195
  env_yaml
170
196
  end
171
- # rubocop:enable MethodLength, LineLength
197
+ # rubocop:enable MethodLength, LineLength, CyclomaticComplexity, PerceivedComplexity
172
198
 
173
- # Private: construct a node hostname from parameters
174
- #
175
- # Params
176
- # component: Hash, environment components
177
- # instance: integer, passed from loop iterator
178
- #
179
- # Returns hostname as String
180
199
  # rubocop:disable MethodLength
200
+
201
+ # Construct a node hostname from parameters
202
+ #
203
+ # @param [Hash] component Hash, environment components
204
+ # @param [integer] instance integer, passed from loop iterator
205
+ # @return [String] hostname
181
206
  def node_name(component, instance)
182
207
  name = ''
183
208
  @nodenameconvention.each do |i|
@@ -198,22 +223,24 @@ module Elevage
198
223
  end
199
224
  # rubocop:enable MethodLength
200
225
 
201
- # Private: Constructs the node runlist from parameters
202
- #
203
- # Params
204
- # list: Array of strings from component runlist hash key value
205
- # componentrole: String value from component, performs simple
206
- # string substitution of for component string
207
- # in component role string
208
- # component: String, component name
209
- #
210
- # Returns runlist as String
211
226
  # rubocop:disable LineLength
227
+
228
+ # Constructs the node runlist from parameters
229
+ #
230
+ # @param [Array] list Array of strings from component runlist hash key
231
+ # value
232
+ # @param [String] componentrole String value from component, performs
233
+ # simple string substitution of component string in component role string
234
+ # @param [String] component Name of the component
235
+ # @return [String] Chef runlist
212
236
  def run_list(list, componentrole, component)
213
237
  list.join(',') + (componentrole ? ',' + componentrole.gsub('#', component) : '')
214
238
  end
215
239
  # rubocop:enable LineLength
216
240
 
241
+ # Ensure the environment file exists
242
+ # @param [String] env_file Environment file name
243
+ # @return [Boolean] True if `env_file` exists
217
244
  def env_file_exists?(env_file)
218
245
  fail(IOError, ERR[:no_environment_file]) unless File.file?(env_file)
219
246
  true
@@ -11,13 +11,14 @@ module Elevage
11
11
  end
12
12
 
13
13
  # rubocop:disable MethodLength, CyclomaticComplexity, PerceivedComplexity
14
+
15
+ # Process the `generate` command to create a new environment file
14
16
  def create_environment
15
17
  fail IOError, ERR[:env_exists] if File.file?(ENV_FOLDER + env + '.yml')
16
18
  platform = Elevage::Platform.new
17
19
  platformfile = File.open(YML_PLATFORM, 'r')
18
- #
19
- # The things from here forward I would rather have in the template file
20
- # but that is even uglier, trying to get formatting correct
20
+ # TODO: The things from here forward I would rather have in the template
21
+ # file but that is even uglier, trying to get formatting correct
21
22
  # will need to investigate some POWER erb skills to clean this up
22
23
  @env_pools = ''
23
24
  @env_components = ''
@@ -10,6 +10,8 @@ module Elevage
10
10
  end
11
11
 
12
12
  # rubocop:disable LineLength
13
+
14
+ # Check the platform definition correctness
13
15
  def check_platform
14
16
  @platform = Elevage::Platform.new
15
17
  puts @platform.healthy? ? MSG_HEALTHY : fail(IOError, ERR[:fail_health_check])
@@ -17,6 +19,8 @@ module Elevage
17
19
  # rubocop:enable LineLength
18
20
 
19
21
  # rubocop:disable LineLength
22
+
23
+ # Check each environment definition for correctness
20
24
  def check_environments
21
25
  @platform.environments.each do |env|
22
26
  puts Elevage::Environment.new(env).healthy? ? (env + MSG_ENV_HEALTHY) : fail(IOError, ERR[:fail_health_check])
data/lib/elevage/new.rb CHANGED
@@ -11,16 +11,18 @@ module Elevage
11
11
  File.dirname(__FILE__)
12
12
  end
13
13
 
14
- # Confirm command is not being run in folder with
15
- # existing platform definition
14
+ # Confirm command is not being run in folder with existing platform
15
+ # definition
16
16
  def already_exists?
17
17
  File.file?(YML_PLATFORM) && fail(IOError, ERR[:platform_exists])
18
18
  end
19
19
 
20
+ # Create the platform definition file
20
21
  def create_platform_file
21
22
  template(TEMPLATE_PLATFORM, YML_PLATFORM)
22
23
  end
23
24
 
25
+ # Create the infrastructure definition files
24
26
  def create_infrastructure_files
25
27
  template(TEMPLATE_VCENTER, YML_VCENTER)
26
28
  template(TEMPLATE_NETWORK, YML_NETWORK)