singel 0.2.2 → 0.2.3
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 +4 -4
- data/.travis.yml +6 -3
- data/Gemfile +1 -6
- data/bin/singel +2 -7
- data/lib/singel.rb +108 -0
- data/lib/{config.rb → singel/config.rb} +0 -0
- data/lib/{executor.rb → singel/executor.rb} +1 -1
- data/lib/{template.rb → singel/template.rb} +3 -0
- data/lib/{uploader.rb → singel/uploader.rb} +0 -0
- data/singel.gemspec +2 -2
- metadata +9 -9
- data/lib/orchestrator.rb +0 -106
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 93309ed4bb6ca45ba817b03388085fb3f5fe8b9a
|
4
|
+
data.tar.gz: 8607257c32a674deac60097d3e88349fabe5d4fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8aa63e39b2eb98bcfcbe4af326a3e996c178bbc1e6e8ef48913c53afd60d4396c4f3bf7b37cf4f2cffb767a05d64032f6ca63d382d485a9db7bc2aab0cb53fa0
|
7
|
+
data.tar.gz: 1652fe4e7d25d9ac23e99cbdc18ed63844047ae3aa4518466a6d019768e28cd305be73beac370570662a4752927ab5c90c940bc324b8a9f4bbbacb23c975c0e6
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/bin/singel
CHANGED
@@ -25,14 +25,9 @@ begin
|
|
25
25
|
require 'aws-sdk-core'
|
26
26
|
require 'json'
|
27
27
|
require 'pty'
|
28
|
-
require '
|
29
|
-
require 'orchestrator.rb'
|
30
|
-
require 'executor.rb'
|
31
|
-
require 'uploader.rb'
|
32
|
-
require 'template.rb'
|
33
|
-
require 'string.rb'
|
28
|
+
require 'singel.rb'
|
34
29
|
rescue LoadError => e
|
35
30
|
raise "Missing gem or lib #{e}"
|
36
31
|
end
|
37
32
|
|
38
|
-
Singel
|
33
|
+
Singel.run
|
data/lib/singel.rb
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
#
|
3
|
+
# Author:: Tim Smith (<tim@cozy.co>)
|
4
|
+
# Copyright:: Copyright (c) 2014 Tim Smith
|
5
|
+
# License:: Apache License, Version 2.0
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
|
19
|
+
# main orchestrator of singel runs
|
20
|
+
module Singel
|
21
|
+
require 'singel/config.rb'
|
22
|
+
require 'singel/executor.rb'
|
23
|
+
require 'singel/uploader.rb'
|
24
|
+
require 'singel/template.rb'
|
25
|
+
require 'string.rb'
|
26
|
+
|
27
|
+
include Singel::Config
|
28
|
+
|
29
|
+
# main method used to kick off the run
|
30
|
+
def self::run
|
31
|
+
@options = Config.config
|
32
|
+
puts "\nsingel - unified image creation tool"
|
33
|
+
puts "-----------------------------------------\n\n"
|
34
|
+
|
35
|
+
check_dirs
|
36
|
+
check_executables
|
37
|
+
@templates = find_templates
|
38
|
+
check_aws_keys
|
39
|
+
|
40
|
+
execute_command(ARGV[0])
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
# check to make sure the packer dir exists
|
46
|
+
def self::check_dirs
|
47
|
+
unless Dir.exist?(@options[:packer_dir])
|
48
|
+
puts "#{@options[:packer_dir]} not present.".to_red
|
49
|
+
puts "See help for information on specifying an alternate dir.\n".to_red
|
50
|
+
exit!
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
# make a test connection using the AWS keys to determine if they're valid
|
55
|
+
def self::check_aws_keys
|
56
|
+
ec2 = Aws::EC2::Client.new(region: 'us-east-1')
|
57
|
+
ec2.describe_instance_status
|
58
|
+
rescue
|
59
|
+
puts 'Could not connect to EC2. Check your local AWS credentials before continuing.'.to_red
|
60
|
+
exit!
|
61
|
+
end
|
62
|
+
|
63
|
+
# check to make sure the prereq binaries present
|
64
|
+
def self::check_executables
|
65
|
+
{ 'Virtualbox' => 'vboxwebsrv', 'Packer' => 'packer' }.each_pair do |name, binary|
|
66
|
+
`which #{binary} 2>&1`
|
67
|
+
unless $CHILD_STATUS.success?
|
68
|
+
puts "Could not find #{name} binary #{binary}. You must install #{name} before continuing.".to_red unless $CHILD_STATUS
|
69
|
+
exit!
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
# find the available packer templates on the host
|
75
|
+
def self::find_templates
|
76
|
+
# find packer templates on disk since none were passed via args
|
77
|
+
if @options[:templates].empty?
|
78
|
+
templates = []
|
79
|
+
Dir.foreach(@options[:packer_dir]) do |item|
|
80
|
+
templates << File.join(@options[:packer_dir], item) if File.extname(item).downcase == '.json'
|
81
|
+
end
|
82
|
+
|
83
|
+
# throw and error and exist if we still dont find any templates
|
84
|
+
if templates.empty?
|
85
|
+
puts "No packer templates found in the 'packer' dir. Cannot continue.".to_red
|
86
|
+
exit!
|
87
|
+
end
|
88
|
+
templates
|
89
|
+
else # parse the arg provided template list
|
90
|
+
@options[:templates].map { |x| File.join(@options[:packer_dir], x) }
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
# run the passed command per packer template
|
95
|
+
def self::execute_command(cmd)
|
96
|
+
@templates.each do |t|
|
97
|
+
template = PackerTemplate.new(t)
|
98
|
+
executor = PackerExecutor.new(template, @options[:builders])
|
99
|
+
puts "Packer template validation for #{template.path} failed.\n".to_red unless template.validates?
|
100
|
+
begin
|
101
|
+
executor.send(cmd)
|
102
|
+
rescue NoMethodError
|
103
|
+
puts "Action \"#{cmd}\" not found. Cannot continue".to_red
|
104
|
+
exit!
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
File without changes
|
@@ -54,7 +54,7 @@ module Singel
|
|
54
54
|
PTY.spawn(command) do |r, _w, pid|
|
55
55
|
begin
|
56
56
|
r.each { |line| print line; }
|
57
|
-
rescue Errno::EIO
|
57
|
+
rescue Errno::EIO # rubocop: disable Lint/HandleExceptions
|
58
58
|
# this is an expected behavior when an app is done sending output
|
59
59
|
ensure
|
60
60
|
Process.wait(pid)
|
File without changes
|
data/singel.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'singel'
|
3
|
-
s.version = '0.2.
|
3
|
+
s.version = '0.2.3'
|
4
4
|
s.date = Date.today.to_s
|
5
5
|
s.platform = Gem::Platform::RUBY
|
6
6
|
s.extra_rdoc_files = ['README.md', 'LICENSE']
|
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
|
|
14
14
|
s.required_ruby_version = '>= 1.9.3'
|
15
15
|
s.add_dependency 'aws-sdk-core'
|
16
16
|
s.add_development_dependency 'rake', '~> 10.0'
|
17
|
-
s.add_development_dependency 'rubocop', '~> 0.
|
17
|
+
s.add_development_dependency 'rubocop', '~> 0.30.0'
|
18
18
|
|
19
19
|
s.files = `git ls-files -z`.split("\x0")
|
20
20
|
s.executables = s.name
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: singel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Smith
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-core
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - ~>
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.
|
47
|
+
version: 0.30.0
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.
|
54
|
+
version: 0.30.0
|
55
55
|
description: Unified system image creation using Packer
|
56
56
|
email: tim@cozy.co
|
57
57
|
executables:
|
@@ -68,12 +68,12 @@ files:
|
|
68
68
|
- README.md
|
69
69
|
- Rakefile
|
70
70
|
- bin/singel
|
71
|
-
- lib/
|
72
|
-
- lib/
|
73
|
-
- lib/
|
71
|
+
- lib/singel.rb
|
72
|
+
- lib/singel/config.rb
|
73
|
+
- lib/singel/executor.rb
|
74
|
+
- lib/singel/template.rb
|
75
|
+
- lib/singel/uploader.rb
|
74
76
|
- lib/string.rb
|
75
|
-
- lib/template.rb
|
76
|
-
- lib/uploader.rb
|
77
77
|
- singel.gemspec
|
78
78
|
homepage: http://www.github.com/tas50/singel
|
79
79
|
licenses:
|
data/lib/orchestrator.rb
DELETED
@@ -1,106 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
#
|
3
|
-
# Author:: Tim Smith (<tim@cozy.co>)
|
4
|
-
# Copyright:: Copyright (c) 2014 Tim Smith
|
5
|
-
# License:: Apache License, Version 2.0
|
6
|
-
#
|
7
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
-
# you may not use this file except in compliance with the License.
|
9
|
-
# You may obtain a copy of the License at
|
10
|
-
#
|
11
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
-
#
|
13
|
-
# Unless required by applicable law or agreed to in writing, software
|
14
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
-
# See the License for the specific language governing permissions and
|
17
|
-
# limitations under the License.
|
18
|
-
|
19
|
-
module Singel
|
20
|
-
# class to control validation of configs / prereqs and to
|
21
|
-
# fire off the individual executor instances to build each template
|
22
|
-
class SingelOrchestrator
|
23
|
-
include Singel::Config
|
24
|
-
|
25
|
-
def initialize
|
26
|
-
@options = Singel::Config.config
|
27
|
-
end
|
28
|
-
|
29
|
-
# main method used to kick off the run
|
30
|
-
def run
|
31
|
-
puts "\nsingel - unified image creation tool"
|
32
|
-
puts "-----------------------------------------\n\n"
|
33
|
-
|
34
|
-
check_dirs
|
35
|
-
check_executables
|
36
|
-
@templates = find_templates
|
37
|
-
check_aws_keys
|
38
|
-
|
39
|
-
execute_command(ARGV[0])
|
40
|
-
end
|
41
|
-
|
42
|
-
# check to make sure the packer dir exists
|
43
|
-
def check_dirs
|
44
|
-
unless Dir.exist?(@options[:packer_dir])
|
45
|
-
puts "#{@options[:packer_dir]} not present.".to_red
|
46
|
-
puts "See help for information on specifying an alternate dir.\n".to_red
|
47
|
-
exit!
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
# make a test connection using the AWS keys to determine if they're valid
|
52
|
-
def check_aws_keys
|
53
|
-
ec2 = Aws::EC2::Client.new(region: 'us-east-1')
|
54
|
-
ec2.describe_instance_status
|
55
|
-
rescue
|
56
|
-
puts 'Could not connect to EC2. Check your local AWS credentials before continuing.'.to_red
|
57
|
-
exit!
|
58
|
-
end
|
59
|
-
|
60
|
-
# check to make sure the prereq binaries present
|
61
|
-
def check_executables
|
62
|
-
{ 'Virtualbox' => 'vboxwebsrv', 'Packer' => 'packer' }.each_pair do |name, binary|
|
63
|
-
`which #{binary} 2>&1`
|
64
|
-
unless $CHILD_STATUS.success?
|
65
|
-
puts "Could not find #{name} binary #{binary}. You must install #{name} before continuing.".to_red unless $CHILD_STATUS
|
66
|
-
exit!
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
# find the available packer templates on the host
|
72
|
-
def find_templates
|
73
|
-
# find packer templates on disk since none were passed via args
|
74
|
-
if @options[:templates].empty?
|
75
|
-
templates = []
|
76
|
-
Dir.foreach(@options[:packer_dir]) do |item|
|
77
|
-
templates << File.join(@options[:packer_dir], item) if File.extname(item).downcase == '.json'
|
78
|
-
end
|
79
|
-
|
80
|
-
# throw and error and exist if we still dont find any templates
|
81
|
-
if templates.empty?
|
82
|
-
puts "No packer templates found in the 'packer' dir. Cannot continue.".to_red
|
83
|
-
exit!
|
84
|
-
end
|
85
|
-
templates
|
86
|
-
else # parse the arg provided template list
|
87
|
-
@options[:templates].map { |x| File.join(@options[:packer_dir], x) }
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
# run the passed command per packer template
|
92
|
-
def execute_command(cmd)
|
93
|
-
@templates.each do |t|
|
94
|
-
template = PackerTemplate.new(t)
|
95
|
-
executor = PackerExecutor.new(template, @options[:builders])
|
96
|
-
puts "Packer template validation for #{template.path} failed.\n".to_red unless template.validates?
|
97
|
-
begin
|
98
|
-
executor.send(cmd)
|
99
|
-
rescue NoMethodError
|
100
|
-
puts "Action \"#{cmd}\" not found. Cannot continue".to_red
|
101
|
-
exit!
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|