aws-cfn-stacker 0.0.1 → 0.0.5
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 +5 -13
- data/aws-cfn-stacker.gemspec +5 -0
- data/aws-cfn-stacker.iml +21 -3
- data/bin/cfn-stacker +25 -0
- data/lib/aws/cfn/stacker/base.rb +10 -0
- data/lib/aws/cfn/stacker/mixins/errors.rb +13 -0
- data/lib/aws/cfn/stacker/mixins/logging.rb +18 -0
- data/lib/aws/cfn/stacker/mixins/main.rb +192 -0
- data/lib/aws/cfn/stacker/mixins/options.rb +495 -0
- data/lib/aws/cfn/stacker/mixins/patches.rb +46 -0
- data/lib/aws/cfn/stacker/mixins/prerequisites.rb +188 -0
- data/lib/aws/cfn/stacker/mixins/setup.rb +58 -0
- data/lib/aws/cfn/stacker/version.rb +6 -1
- data/lib/aws/cfn/stacker.rb +21 -1
- metadata +106 -14
@@ -0,0 +1,188 @@
|
|
1
|
+
module Aws
|
2
|
+
module Cfn
|
3
|
+
module Stacker
|
4
|
+
|
5
|
+
module Prerequisites
|
6
|
+
attr :checkRuby
|
7
|
+
|
8
|
+
# -----------------------------------------------------------------------------
|
9
|
+
@TMPDIR = nil
|
10
|
+
def getTmpDir
|
11
|
+
unless @TMPDIR
|
12
|
+
@TMPDIR = ENV.key?('TMPDIR') ? ENV['TMPDIR'] : '/tmp/'
|
13
|
+
end
|
14
|
+
@TMPDIR
|
15
|
+
end
|
16
|
+
|
17
|
+
# -----------------------------------------------------------------------------
|
18
|
+
def checkOS()
|
19
|
+
require 'rbconfig'
|
20
|
+
#OS.mac?
|
21
|
+
unless RbConfig::CONFIG['host_os'] =~ %r/darwin/
|
22
|
+
raise ::Aws::Cfn::Stacker::Errors::SetupError.new("Sorry! Your OS platform (#{RUBY_PLATFORM}) is not yet supported (as of 2014/06/16)!")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# -----------------------------------------------------------------------------
|
27
|
+
def getChefPath(logger)
|
28
|
+
chef = %x(which chef-solo 2>/dev/null).gsub(%r/\s+/, '')
|
29
|
+
unless chef == ''
|
30
|
+
logger.debug "Found chef-solo: '#{chef}'" if logger
|
31
|
+
if File.symlink?(chef)
|
32
|
+
chef = File.readlink(chef)
|
33
|
+
end
|
34
|
+
stat = File.stat(chef)
|
35
|
+
chef = File.dirname(chef)
|
36
|
+
end
|
37
|
+
chef
|
38
|
+
end
|
39
|
+
|
40
|
+
# -----------------------------------------------------------------------------
|
41
|
+
def askForChefRuby(must_chef=true)
|
42
|
+
return unless must_chef
|
43
|
+
embedded_bin = File.expand_path(getChefPath(false)+"/../embedded/bin")
|
44
|
+
puts "Please reissue the command as follows: "
|
45
|
+
aCmd = ["#{embedded_bin}/ruby", $0]
|
46
|
+
aCmd << ARGV.dup
|
47
|
+
aCmd.flatten!
|
48
|
+
puts aCmd.join(' ')
|
49
|
+
exit -1
|
50
|
+
end
|
51
|
+
|
52
|
+
# -----------------------------------------------------------------------------
|
53
|
+
def findChefRuby()
|
54
|
+
embedded_bin = File.expand_path(getChefPath(false)+"/../embedded/bin")
|
55
|
+
embedded_ruby = "#{embedded_bin}/ruby"
|
56
|
+
if File.executable?(embedded_ruby)
|
57
|
+
ruby_version = "\x1b[$38;5;1m"+%x(#{embedded_ruby} -v 2>/dev/null)+"\x1b[0m" # .gsub(%r/\s+/, '')
|
58
|
+
puts "You have a Chef embedded Ruby ... #{ruby_version} ...\n\nYou should place it on the PATH (export PATH=/opt/chef/embedded/bin:#{ENV['PATH']}) or use it directly."
|
59
|
+
return 0
|
60
|
+
end
|
61
|
+
1
|
62
|
+
end
|
63
|
+
|
64
|
+
# -----------------------------------------------------------------------------
|
65
|
+
def yieldChefRuby(&block)
|
66
|
+
if 0 == findChefRuby()
|
67
|
+
askForChefRuby(false)
|
68
|
+
else
|
69
|
+
yield
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
# -----------------------------------------------------------------------------
|
74
|
+
def checkRuby()
|
75
|
+
@checkRuby = 0 if @checkRuby.nil?
|
76
|
+
|
77
|
+
if RUBY_VERSION.match(%r/^(1\.9|2\.)/)
|
78
|
+
begin
|
79
|
+
ENV.delete('GEM_PATH')
|
80
|
+
ENV.delete('GEM_HOME')
|
81
|
+
require "chef/version"
|
82
|
+
rescue LoadError => e
|
83
|
+
puts "Your Ruby is new enough but you do not seem to have the Chef gem installed!"
|
84
|
+
yieldChefRuby {
|
85
|
+
puts "Chef is not essential right now ... ignoring"
|
86
|
+
}
|
87
|
+
end
|
88
|
+
else
|
89
|
+
puts "Sorry! Your Ruby version (#{RUBY_VERSION}) is too low!\nYou need at least 1.9.3."
|
90
|
+
|
91
|
+
yieldChefRuby {
|
92
|
+
if ARGV.include?('--install-chef')
|
93
|
+
installChef()
|
94
|
+
puts "Checking Ruby again ... "
|
95
|
+
@checkRuby += 1
|
96
|
+
checkRuby() unless @checkRuby > 1
|
97
|
+
else
|
98
|
+
puts "
|
99
|
+
|
100
|
+
You can get a newer version of Ruby with Chef Omnibus installer.
|
101
|
+
|
102
|
+
Option 1: Provide the --install-chef option
|
103
|
+
|
104
|
+
Option 2: Install Chef yourself
|
105
|
+
1) Install Chef with: 'curl -L https://www.opscode.com/chef/install.sh | sudo bash'
|
106
|
+
2) Run this script with: '/opt/chef/embedded/bin/ruby #{$0} #{ARGV.clone.join(' ')}'
|
107
|
+
|
108
|
+
|
109
|
+
"
|
110
|
+
raise ::Aws::Cfn::Stacker::Errors::SetupError.new("Sorry! Your Ruby version (#{RUBY_VERSION}) is too low!")
|
111
|
+
end
|
112
|
+
}
|
113
|
+
end
|
114
|
+
|
115
|
+
end
|
116
|
+
|
117
|
+
# -----------------------------------------------------------------------------
|
118
|
+
def installChef()
|
119
|
+
STDOUT.sync = true
|
120
|
+
STDERR.sync = true
|
121
|
+
#logger = getLogger(ARGV.hash)
|
122
|
+
chef_installer = 'chef-11.6.0_1.mac_os_x.10.7.2.sh'
|
123
|
+
tmp = getTmpDir()
|
124
|
+
url = "https://opscode-omnibus-packages.s3.amazonaws.com/mac_os_x/10.7/x86_64/#{chef_installer}"
|
125
|
+
puts "Installing Chef 11.6.0_1 from #{url}"
|
126
|
+
aCmd = [ 'curl', '--silent', '-o', "#{tmp}/#{chef_installer}", "-L", url ]
|
127
|
+
puts aCmd.join(' ')
|
128
|
+
#rc = executeTask( aCmd, { :rc => 0, :msg => 'Success' }, [] )
|
129
|
+
cond = {
|
130
|
+
:logit => true,
|
131
|
+
:rc => 0,
|
132
|
+
:msg => 'Success',
|
133
|
+
}
|
134
|
+
|
135
|
+
pid = fork do
|
136
|
+
ret = system(aCmd.join(' '))
|
137
|
+
#logger.debug "[child] system(): #{ret}"
|
138
|
+
exit ret === true ? 0 : -1
|
139
|
+
end
|
140
|
+
|
141
|
+
pid,status = Process.waitpid2(pid)
|
142
|
+
rc = status.exitstatus
|
143
|
+
if rc != 0
|
144
|
+
cond[:msg] = "The uninstaller did not complete or did not succeed possibly because administrative privileges were not authorized."
|
145
|
+
end
|
146
|
+
|
147
|
+
raise ::Aws::Cfn::Stacker::Errors::SetupError.new("Sorry, cannot download Chef installer") unless rc == 0
|
148
|
+
|
149
|
+
puts "\nI am going to execute a sudo command now: 'sudo #{tmp}/#{chef_installer}'\nPlease type your sudo password when prompted!\n"
|
150
|
+
aCmd = [ 'sudo', 'bash', "#{tmp}/#{chef_installer}" ]
|
151
|
+
puts aCmd.join(' ')
|
152
|
+
ENV.delete('GEM_PATH')
|
153
|
+
ENV.delete('GEM_HOME')
|
154
|
+
#rc = executeTask( aCmd, { :rc => 0, :msg => 'Success' }, [] )
|
155
|
+
|
156
|
+
cond = {
|
157
|
+
:logit => true,
|
158
|
+
:rc => 0,
|
159
|
+
:msg => 'Success',
|
160
|
+
}
|
161
|
+
|
162
|
+
pid = fork do
|
163
|
+
ret = system(aCmd.join(' '))
|
164
|
+
#logger.debug "[child] system(): #{ret}"
|
165
|
+
exit ret === true ? 0 : -1
|
166
|
+
end
|
167
|
+
|
168
|
+
pid,status = Process.waitpid2(pid)
|
169
|
+
rc = status.exitstatus
|
170
|
+
if rc != 0
|
171
|
+
cond[:msg] = "The uninstaller did not complete or did not succeed possibly because administrative privileges were not authorized."
|
172
|
+
end
|
173
|
+
|
174
|
+
raise ::Aws::Cfn::Stacker::Errors::SetupError.new("Sorry, cannot install Chef") unless rc == 0
|
175
|
+
|
176
|
+
# Get control back of this new installation
|
177
|
+
puts "We use sudo and may ask you for your password ..."
|
178
|
+
puts %x(sudo chown -R #{ENV['USER']} /opt/chef)
|
179
|
+
puts %x(sudo chmod -R u+w /opt/chef)
|
180
|
+
|
181
|
+
rc
|
182
|
+
end
|
183
|
+
|
184
|
+
end
|
185
|
+
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module Aws
|
2
|
+
module Cfn
|
3
|
+
module Stacker
|
4
|
+
module Setup
|
5
|
+
ENV.delete('GEM_PATH')
|
6
|
+
ENV.delete('GEM_HOME')
|
7
|
+
|
8
|
+
# Standard library gems
|
9
|
+
require "optparse"
|
10
|
+
require 'erb'
|
11
|
+
|
12
|
+
GEMS = [
|
13
|
+
"awesome_print",
|
14
|
+
"colorize",
|
15
|
+
"inifile",
|
16
|
+
"logging",
|
17
|
+
"chef",
|
18
|
+
]
|
19
|
+
|
20
|
+
# =============================================================================
|
21
|
+
# Check for gems we need
|
22
|
+
require "rubygems"
|
23
|
+
require 'rubygems/gem_runner'
|
24
|
+
require 'rubygems/exceptions'
|
25
|
+
GEMS.each{ |g|
|
26
|
+
begin
|
27
|
+
gem g
|
28
|
+
rescue Gem::LoadError
|
29
|
+
# not installed
|
30
|
+
#puts %x(gem install #{g})
|
31
|
+
begin
|
32
|
+
puts "Need to install #{g}"
|
33
|
+
args = ['install', g, '--no-rdoc', '--no-ri']
|
34
|
+
Gem::GemRunner.new.run args
|
35
|
+
rescue Gem::SystemExitException => e
|
36
|
+
unless e.exit_code == 0
|
37
|
+
puts "ERROR: Failed to install #{g}. #{e.message}"
|
38
|
+
raise e
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
}
|
43
|
+
|
44
|
+
# Add-on gems
|
45
|
+
GEMS.map{ |g| require g }
|
46
|
+
|
47
|
+
|
48
|
+
#############################################################
|
49
|
+
## FUNCTIONS
|
50
|
+
|
51
|
+
## FUNCTIONS
|
52
|
+
#############################################################
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
data/lib/aws/cfn/stacker.rb
CHANGED
@@ -1,9 +1,29 @@
|
|
1
|
+
# Setup
|
2
|
+
%w(Patches Errors Prerequisites ).each { |m|
|
3
|
+
require "aws/cfn/stacker/mixins/#{m.downcase}"
|
4
|
+
eval "include Aws::Cfn::Stacker::#{m}"
|
5
|
+
}
|
6
|
+
|
7
|
+
checkOS()
|
8
|
+
checkRuby()
|
9
|
+
|
1
10
|
require "aws/cfn/stacker/version"
|
11
|
+
require "aws/cfn/stacker/base"
|
2
12
|
|
3
13
|
module Aws
|
4
14
|
module Cfn
|
5
15
|
module Stacker
|
6
|
-
#
|
16
|
+
# noinspection RubyTooManyInstanceVariablesInspection,RubyTooManyMethodsInspection
|
17
|
+
class Application
|
18
|
+
require 'dldinternet/mixlib/cli'
|
19
|
+
include ::DLDInternet::Mixlib::CLI
|
20
|
+
|
21
|
+
%w(Main Options Logging).each { |m|
|
22
|
+
require "aws/cfn/stacker/mixins/#{m.downcase}"
|
23
|
+
eval "include Aws::Cfn::Stacker::#{m}"
|
24
|
+
}
|
25
|
+
|
26
|
+
end
|
7
27
|
end
|
8
28
|
end
|
9
29
|
end
|
metadata
CHANGED
@@ -1,72 +1,155 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aws-cfn-stacker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christo De Lange
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: awesome_print
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: colorize
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: inifile
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: dldinternet-mixlib-cli
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.1.0
|
62
|
+
- - "~>"
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0.1'
|
65
|
+
type: :runtime
|
66
|
+
prerelease: false
|
67
|
+
version_requirements: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: 0.1.0
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0.1'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: dldinternet-mixlib-logging
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: 0.1.5
|
82
|
+
- - "~>"
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0.1'
|
85
|
+
type: :runtime
|
86
|
+
prerelease: false
|
87
|
+
version_requirements: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: 0.1.5
|
92
|
+
- - "~>"
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0.1'
|
13
95
|
- !ruby/object:Gem::Dependency
|
14
96
|
name: aws-cfn-yats
|
15
97
|
requirement: !ruby/object:Gem::Requirement
|
16
98
|
requirements:
|
17
|
-
- -
|
99
|
+
- - ">="
|
18
100
|
- !ruby/object:Gem::Version
|
19
101
|
version: 0.1.6
|
20
|
-
- - ~>
|
102
|
+
- - "~>"
|
21
103
|
- !ruby/object:Gem::Version
|
22
104
|
version: '0.1'
|
23
105
|
type: :runtime
|
24
106
|
prerelease: false
|
25
107
|
version_requirements: !ruby/object:Gem::Requirement
|
26
108
|
requirements:
|
27
|
-
- -
|
109
|
+
- - ">="
|
28
110
|
- !ruby/object:Gem::Version
|
29
111
|
version: 0.1.6
|
30
|
-
- - ~>
|
112
|
+
- - "~>"
|
31
113
|
- !ruby/object:Gem::Version
|
32
114
|
version: '0.1'
|
33
115
|
- !ruby/object:Gem::Dependency
|
34
116
|
name: bundler
|
35
117
|
requirement: !ruby/object:Gem::Requirement
|
36
118
|
requirements:
|
37
|
-
- - ~>
|
119
|
+
- - "~>"
|
38
120
|
- !ruby/object:Gem::Version
|
39
121
|
version: '1.6'
|
40
122
|
type: :development
|
41
123
|
prerelease: false
|
42
124
|
version_requirements: !ruby/object:Gem::Requirement
|
43
125
|
requirements:
|
44
|
-
- - ~>
|
126
|
+
- - "~>"
|
45
127
|
- !ruby/object:Gem::Version
|
46
128
|
version: '1.6'
|
47
129
|
- !ruby/object:Gem::Dependency
|
48
130
|
name: rake
|
49
131
|
requirement: !ruby/object:Gem::Requirement
|
50
132
|
requirements:
|
51
|
-
- -
|
133
|
+
- - ">="
|
52
134
|
- !ruby/object:Gem::Version
|
53
135
|
version: '0'
|
54
136
|
type: :development
|
55
137
|
prerelease: false
|
56
138
|
version_requirements: !ruby/object:Gem::Requirement
|
57
139
|
requirements:
|
58
|
-
- -
|
140
|
+
- - ">="
|
59
141
|
- !ruby/object:Gem::Version
|
60
142
|
version: '0'
|
61
143
|
description: A CloudFormation stack management helper to do stack CRUD and chaining.
|
62
144
|
It eases the pain of setting up parameters and chaining stacks.
|
63
145
|
email:
|
64
146
|
- rubygems@dldinternet.com
|
65
|
-
executables:
|
147
|
+
executables:
|
148
|
+
- cfn-stacker
|
66
149
|
extensions: []
|
67
150
|
extra_rdoc_files: []
|
68
151
|
files:
|
69
|
-
- .gitignore
|
152
|
+
- ".gitignore"
|
70
153
|
- Gemfile
|
71
154
|
- LICENSE
|
72
155
|
- LICENSE.txt
|
@@ -74,7 +157,16 @@ files:
|
|
74
157
|
- Rakefile
|
75
158
|
- aws-cfn-stacker.gemspec
|
76
159
|
- aws-cfn-stacker.iml
|
160
|
+
- bin/cfn-stacker
|
77
161
|
- lib/aws/cfn/stacker.rb
|
162
|
+
- lib/aws/cfn/stacker/base.rb
|
163
|
+
- lib/aws/cfn/stacker/mixins/errors.rb
|
164
|
+
- lib/aws/cfn/stacker/mixins/logging.rb
|
165
|
+
- lib/aws/cfn/stacker/mixins/main.rb
|
166
|
+
- lib/aws/cfn/stacker/mixins/options.rb
|
167
|
+
- lib/aws/cfn/stacker/mixins/patches.rb
|
168
|
+
- lib/aws/cfn/stacker/mixins/prerequisites.rb
|
169
|
+
- lib/aws/cfn/stacker/mixins/setup.rb
|
78
170
|
- lib/aws/cfn/stacker/version.rb
|
79
171
|
homepage: ''
|
80
172
|
licenses:
|
@@ -86,12 +178,12 @@ require_paths:
|
|
86
178
|
- lib
|
87
179
|
required_ruby_version: !ruby/object:Gem::Requirement
|
88
180
|
requirements:
|
89
|
-
- -
|
181
|
+
- - ">="
|
90
182
|
- !ruby/object:Gem::Version
|
91
183
|
version: '0'
|
92
184
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
185
|
requirements:
|
94
|
-
- -
|
186
|
+
- - ">="
|
95
187
|
- !ruby/object:Gem::Version
|
96
188
|
version: '0'
|
97
189
|
requirements: []
|