formatron 0.1.14 → 0.1.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/formatron.gemspec +2 -1
- data/lib/formatron.rb +23 -10
- data/lib/formatron/aws.rb +26 -13
- data/lib/formatron/chef.rb +53 -9
- data/lib/formatron/chef/berkshelf.rb +15 -11
- data/lib/formatron/chef/keys.rb +5 -9
- data/lib/formatron/chef/knife.rb +39 -30
- data/lib/formatron/chef/ssh.rb +4 -1
- data/lib/formatron/chef/winrm.rb +37 -0
- data/lib/formatron/chef_clients.rb +6 -4
- data/lib/formatron/cli/generators/credentials.rb +1 -1
- data/lib/formatron/cloud_formation/resources/ec2.rb +58 -57
- data/lib/formatron/cloud_formation/scripts.rb +75 -3
- data/lib/formatron/cloud_formation/template.rb +6 -0
- data/lib/formatron/cloud_formation/template/vpc.rb +8 -0
- data/lib/formatron/cloud_formation/template/vpc/subnet.rb +8 -0
- data/lib/formatron/cloud_formation/template/vpc/subnet/bastion.rb +12 -0
- data/lib/formatron/cloud_formation/template/vpc/subnet/chef_server.rb +12 -0
- data/lib/formatron/cloud_formation/template/vpc/subnet/instance.rb +13 -2
- data/lib/formatron/cloud_formation/template/vpc/subnet/instance/security_group.rb +47 -2
- data/lib/formatron/cloud_formation/template/vpc/subnet/instance/setup.rb +92 -27
- data/lib/formatron/cloud_formation/template/vpc/subnet/nat.rb +12 -0
- data/lib/formatron/dsl/formatron/global.rb +2 -0
- data/lib/formatron/dsl/formatron/global/windows.rb +17 -0
- data/lib/formatron/dsl/formatron/vpc/subnet/instance.rb +1 -0
- data/lib/formatron/external/dsl.rb +19 -0
- data/lib/formatron/util/winrm.rb +40 -0
- data/lib/formatron/version.rb +1 -1
- metadata +33 -16
@@ -15,6 +15,8 @@ class Formatron
|
|
15
15
|
def initialize(
|
16
16
|
nat:,
|
17
17
|
key_pair:,
|
18
|
+
administrator_name:,
|
19
|
+
administrator_password:,
|
18
20
|
availability_zone:,
|
19
21
|
subnet_guid:,
|
20
22
|
hosted_zone_name:,
|
@@ -34,11 +36,14 @@ class Formatron
|
|
34
36
|
@instance_id = "#{Instance::INSTANCE_PREFIX}#{guid}"
|
35
37
|
@route_table_id = "#{ROUTE_TABLE_PREFIX}#{guid}"
|
36
38
|
@route_id = "#{ROUTE_PREFIX}#{guid}"
|
39
|
+
_set_os
|
37
40
|
_add_setup_script
|
38
41
|
_set_source_dest_check
|
39
42
|
@instance = Instance.new(
|
40
43
|
instance: nat,
|
41
44
|
key_pair: key_pair,
|
45
|
+
administrator_name: administrator_name,
|
46
|
+
administrator_password: administrator_password,
|
42
47
|
availability_zone: availability_zone,
|
43
48
|
subnet_guid: subnet_guid,
|
44
49
|
hosted_zone_name: hosted_zone_name,
|
@@ -55,6 +60,12 @@ class Formatron
|
|
55
60
|
# rubocop:enable Metrics/ParameterLists
|
56
61
|
# rubocop:enable Metrics/MethodLength
|
57
62
|
|
63
|
+
def _set_os
|
64
|
+
@nat.os(
|
65
|
+
'ubuntu'
|
66
|
+
)
|
67
|
+
end
|
68
|
+
|
58
69
|
def _add_setup_script
|
59
70
|
@nat.setup do |setup|
|
60
71
|
scripts = setup.script
|
@@ -82,6 +93,7 @@ class Formatron
|
|
82
93
|
end
|
83
94
|
|
84
95
|
private(
|
96
|
+
:_set_os,
|
85
97
|
:_set_source_dest_check,
|
86
98
|
:_add_setup_script,
|
87
99
|
:_add_route_table
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'formatron/util/dsl'
|
2
2
|
require_relative 'global/ec2'
|
3
|
+
require_relative 'global/windows'
|
3
4
|
|
4
5
|
class Formatron
|
5
6
|
class DSL
|
@@ -18,6 +19,7 @@ class Formatron
|
|
18
19
|
dsl_property :kms_key
|
19
20
|
dsl_property :databag_secret
|
20
21
|
dsl_block :ec2, 'EC2'
|
22
|
+
dsl_block :windows, 'Windows'
|
21
23
|
|
22
24
|
def hosted_zone_id(value = nil)
|
23
25
|
unless value.nil?
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'formatron/util/dsl'
|
2
|
+
|
3
|
+
class Formatron
|
4
|
+
class DSL
|
5
|
+
class Formatron
|
6
|
+
class Global
|
7
|
+
# Windows authentication parameters
|
8
|
+
class Windows
|
9
|
+
extend Util::DSL
|
10
|
+
dsl_initialize_block
|
11
|
+
dsl_property :administrator_name
|
12
|
+
dsl_property :administrator_password
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -35,6 +35,15 @@ class Formatron
|
|
35
35
|
new_ec2['private_key']
|
36
36
|
) unless new_ec2['private_key'].nil?
|
37
37
|
end unless new_ec2.nil?
|
38
|
+
new_windows = new_global['windows']
|
39
|
+
global.windows do |windows|
|
40
|
+
windows.administrator_name(
|
41
|
+
new_windows['administrator_name']
|
42
|
+
) unless new_windows['administrator_name'].nil?
|
43
|
+
windows.administrator_password(
|
44
|
+
new_windows['administrator_password']
|
45
|
+
) unless new_windows['administrator_password'].nil?
|
46
|
+
end unless new_windows.nil?
|
38
47
|
end unless new_global.nil?
|
39
48
|
new_vpcs = configuration['vpcs']
|
40
49
|
new_vpcs.each do |vpc_key, new_vpc|
|
@@ -116,6 +125,16 @@ class Formatron
|
|
116
125
|
configuration_ec2['private_key'] =
|
117
126
|
ec2.private_key unless ec2.private_key.nil?
|
118
127
|
end
|
128
|
+
windows = global.windows
|
129
|
+
unless windows.nil?
|
130
|
+
configuration_windows = configuration_global['windows'] = {}
|
131
|
+
configuration_windows['administrator_name'] =
|
132
|
+
windows.administrator_name unless windows.administrator_name.nil?
|
133
|
+
# rubocop:disable Metrics/LineLength
|
134
|
+
configuration_windows['administrator_password'] =
|
135
|
+
windows.administrator_password unless windows.administrator_password.nil?
|
136
|
+
# rubocop:enable Metrics/LineLength
|
137
|
+
end
|
119
138
|
end
|
120
139
|
vpcs.each do |vpc_key, vpc|
|
121
140
|
vpc_configuration = configuration['vpcs'][vpc_key] = {
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'winrm'
|
2
|
+
require 'formatron/logger'
|
3
|
+
|
4
|
+
class Formatron
|
5
|
+
module Util
|
6
|
+
# Perform commands on chef nodes over WinRM
|
7
|
+
class WinRM
|
8
|
+
# rubocop:disable Metrics/MethodLength
|
9
|
+
def self.exec(
|
10
|
+
hostname:,
|
11
|
+
administrator_name:,
|
12
|
+
administrator_password:,
|
13
|
+
command:
|
14
|
+
)
|
15
|
+
endpoint = "http://#{hostname}:5985/wsman"
|
16
|
+
winrm = ::WinRM::WinRMWebService.new(
|
17
|
+
endpoint,
|
18
|
+
:negotiate,
|
19
|
+
user: administrator_name,
|
20
|
+
pass: administrator_password
|
21
|
+
)
|
22
|
+
output = winrm.create_executor do |executor|
|
23
|
+
executor.run_powershell_script(command) do |stdout, stderr|
|
24
|
+
stdout.each_line do |line|
|
25
|
+
Formatron::LOG.info { line.chomp }
|
26
|
+
end unless stdout.nil?
|
27
|
+
stderr.each_line do |line|
|
28
|
+
Formatron::LOG.warn { line.chomp }
|
29
|
+
end unless stderr.nil?
|
30
|
+
end
|
31
|
+
end
|
32
|
+
exitcode = output[:exitcode]
|
33
|
+
fail(
|
34
|
+
"`#{command}` exited with code #{exitcode}"
|
35
|
+
) unless exitcode == 0
|
36
|
+
end
|
37
|
+
# rubocop:enable Metrics/MethodLength
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/lib/formatron/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: formatron
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Halliday
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-03-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -136,20 +136,6 @@ dependencies:
|
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0.8'
|
139
|
-
- !ruby/object:Gem::Dependency
|
140
|
-
name: codacy-coverage
|
141
|
-
requirement: !ruby/object:Gem::Requirement
|
142
|
-
requirements:
|
143
|
-
- - "~>"
|
144
|
-
- !ruby/object:Gem::Version
|
145
|
-
version: '0.3'
|
146
|
-
type: :development
|
147
|
-
prerelease: false
|
148
|
-
version_requirements: !ruby/object:Gem::Requirement
|
149
|
-
requirements:
|
150
|
-
- - "~>"
|
151
|
-
- !ruby/object:Gem::Version
|
152
|
-
version: '0.3'
|
153
139
|
- !ruby/object:Gem::Dependency
|
154
140
|
name: rubocop
|
155
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -290,6 +276,20 @@ dependencies:
|
|
290
276
|
- - "~>"
|
291
277
|
- !ruby/object:Gem::Version
|
292
278
|
version: '12.5'
|
279
|
+
- !ruby/object:Gem::Dependency
|
280
|
+
name: knife-windows
|
281
|
+
requirement: !ruby/object:Gem::Requirement
|
282
|
+
requirements:
|
283
|
+
- - "~>"
|
284
|
+
- !ruby/object:Gem::Version
|
285
|
+
version: '1.3'
|
286
|
+
type: :runtime
|
287
|
+
prerelease: false
|
288
|
+
version_requirements: !ruby/object:Gem::Requirement
|
289
|
+
requirements:
|
290
|
+
- - "~>"
|
291
|
+
- !ruby/object:Gem::Version
|
292
|
+
version: '1.3'
|
293
293
|
- !ruby/object:Gem::Dependency
|
294
294
|
name: net-ssh
|
295
295
|
requirement: !ruby/object:Gem::Requirement
|
@@ -304,6 +304,20 @@ dependencies:
|
|
304
304
|
- - "~>"
|
305
305
|
- !ruby/object:Gem::Version
|
306
306
|
version: '2.9'
|
307
|
+
- !ruby/object:Gem::Dependency
|
308
|
+
name: winrm
|
309
|
+
requirement: !ruby/object:Gem::Requirement
|
310
|
+
requirements:
|
311
|
+
- - "~>"
|
312
|
+
- !ruby/object:Gem::Version
|
313
|
+
version: '1.7'
|
314
|
+
type: :runtime
|
315
|
+
prerelease: false
|
316
|
+
version_requirements: !ruby/object:Gem::Requirement
|
317
|
+
requirements:
|
318
|
+
- - "~>"
|
319
|
+
- !ruby/object:Gem::Version
|
320
|
+
version: '1.7'
|
307
321
|
description: |
|
308
322
|
AWS/Chef deployment tool based around Chef Server and AWS CloudFormation
|
309
323
|
email:
|
@@ -337,6 +351,7 @@ files:
|
|
337
351
|
- lib/formatron/chef/keys.rb
|
338
352
|
- lib/formatron/chef/knife.rb
|
339
353
|
- lib/formatron/chef/ssh.rb
|
354
|
+
- lib/formatron/chef/winrm.rb
|
340
355
|
- lib/formatron/chef_clients.rb
|
341
356
|
- lib/formatron/cli.rb
|
342
357
|
- lib/formatron/cli/completion.rb
|
@@ -375,6 +390,7 @@ files:
|
|
375
390
|
- lib/formatron/dsl/formatron.rb
|
376
391
|
- lib/formatron/dsl/formatron/global.rb
|
377
392
|
- lib/formatron/dsl/formatron/global/ec2.rb
|
393
|
+
- lib/formatron/dsl/formatron/global/windows.rb
|
378
394
|
- lib/formatron/dsl/formatron/vpc.rb
|
379
395
|
- lib/formatron/dsl/formatron/vpc/subnet.rb
|
380
396
|
- lib/formatron/dsl/formatron/vpc/subnet/acl.rb
|
@@ -417,6 +433,7 @@ files:
|
|
417
433
|
- lib/formatron/util/shell.rb
|
418
434
|
- lib/formatron/util/ssh.rb
|
419
435
|
- lib/formatron/util/vpc.rb
|
436
|
+
- lib/formatron/util/winrm.rb
|
420
437
|
- lib/formatron/version.rb
|
421
438
|
- support/cloudformation_describe_stacks_response.rb
|
422
439
|
- support/cloudformation_stack_events_responses.rb
|