elevage 0.1.0 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -1
- data/README.md +33 -11
- data/elevage.gemspec +15 -15
- data/features/archive +3 -22
- data/features/build.feature +2 -1
- data/features/generate.feature +3 -9
- data/features/health_env_failure.feature +2 -8
- data/features/health_failure.feature +1 -2
- data/features/health_success.feature +3 -9
- data/features/list.feature +3 -9
- data/features/step_definitions/elevage_steps.rb +2 -2
- data/lib/elevage/build.rb +4 -1
- data/lib/elevage/constants.rb +2 -2
- data/lib/elevage/environment.rb +66 -39
- data/lib/elevage/generate.rb +4 -3
- data/lib/elevage/health.rb +4 -0
- data/lib/elevage/new.rb +4 -2
- data/lib/elevage/platform.rb +11 -3
- data/lib/elevage/provisioner.rb +61 -21
- data/lib/elevage/provisionerrunqueue.rb +25 -10
- data/lib/elevage/templates/vcenter.yml.tt +7 -12
- data/lib/elevage/version.rb +1 -1
- data/lib/elevage.rb +5 -0
- metadata +58 -88
- data/.ruby-version +0 -1
- data/.yardoc/checksums +0 -12
- data/.yardoc/object_types +0 -0
- data/.yardoc/objects/root.dat +0 -0
- data/.yardoc/proxy_types +0 -0
- data/doc/Elevage/Build.html +0 -435
- data/doc/Elevage/CLI.html +0 -282
- data/doc/Elevage/Environment.html +0 -950
- data/doc/Elevage/Generate.html +0 -346
- data/doc/Elevage/Health.html +0 -359
- data/doc/Elevage/New.html +0 -411
- data/doc/Elevage/Platform.html +0 -1119
- data/doc/Elevage/Provisioner.html +0 -804
- data/doc/Elevage/ProvisionerRunQueue.html +0 -765
- data/doc/Elevage/Runner.html +0 -319
- data/doc/Elevage.html +0 -501
- data/doc/_index.html +0 -239
- data/doc/class_list.html +0 -58
- data/doc/css/common.css +0 -1
- data/doc/css/full_list.css +0 -57
- data/doc/css/style.css +0 -339
- data/doc/file.README.html +0 -187
- data/doc/file_list.html +0 -60
- data/doc/frames.html +0 -26
- data/doc/index.html +0 -187
- data/doc/js/app.js +0 -219
- data/doc/js/full_list.js +0 -181
- data/doc/js/jquery.js +0 -4
- data/doc/method_list.html +0 -369
- data/doc/top-level-namespace.html +0 -112
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 831308271c5d157f33c0c90509d9368ed88652aa
|
4
|
+
data.tar.gz: 87a2972d4ad9e580b8d2d0dfff92a78f8cf28adb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68f1b3bcd8ca570402fbb44c0e1d289c65693fc59fd51205625cfe0f58b47f674c53f6faf611f969eda99cd3992b219021e61e4c57d4a4e7d80b49e4316d85e3
|
7
|
+
data.tar.gz: 868903fced4812feec7cc8e43616c7b9e8d375ab5d7fac49d0a3f1c92c3fa40aa72adaed926dbe9c09ce0729be5d05d7ccb84b9e180c8c89fc6290935f3ebc74
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -1,14 +1,35 @@
|
|
1
1
|
# Elevage
|
2
2
|
|
3
|
-
[![Build Status](https://travis-ci.org/
|
4
|
-
[![Dependency Status](https://gemnasium.com/
|
5
|
-
[![Coverage Status](https://coveralls.io/repos/
|
6
|
-
[![Inline docs](http://inch-ci.org/github/
|
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/
|
9
|
-
[gemnasium]: https://gemnasium.com/
|
10
|
-
[coveralls]: https://coveralls.io/r/
|
11
|
-
[inch]: http://inch-ci.org/github/
|
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/
|
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
|
-
-
|
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
|
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
|
-
|
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
|
-
|
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
|
data/features/build.feature
CHANGED
@@ -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
|
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
|
"""
|
data/features/generate.feature
CHANGED
@@ -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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
103
|
-
- Prod_Cor_03
|
104
|
-
- Prod_Cor_04
|
98
|
+
datastore: 'Prod_Cor'
|
105
99
|
|
106
100
|
domain: corp.local
|
107
101
|
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
|
-
|
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
|
-
|
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"
|
data/features/list.feature
CHANGED
@@ -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
|
-
|
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
|
-
|
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
|
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
|
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])
|
data/lib/elevage/constants.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# rubocop:disable LineLength
|
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
|
113
|
+
# rubocop:enable LineLength
|
data/lib/elevage/environment.rb
CHANGED
@@ -5,8 +5,10 @@ require_relative 'constants'
|
|
5
5
|
require_relative 'platform'
|
6
6
|
require_relative 'provisioner'
|
7
7
|
|
8
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
92
|
-
|
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(
|
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
|
-
#
|
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
|
-
#
|
135
|
-
#
|
136
|
-
#
|
137
|
-
#
|
138
|
-
#
|
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
|
-
|
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
|
-
|
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
|
data/lib/elevage/generate.rb
CHANGED
@@ -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
|
-
#
|
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 = ''
|
data/lib/elevage/health.rb
CHANGED
@@ -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
|
-
#
|
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)
|