labs-deployer 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/labs-deployer.gemspec +6 -0
- data/lib/labs-deployer.rb +23 -28
- data/lib/labs-deployer/version.rb +1 -1
- metadata +37 -5
data/labs-deployer.gemspec
CHANGED
@@ -16,4 +16,10 @@ Gem::Specification.new do |gem|
|
|
16
16
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
17
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
18
|
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
gem.add_dependency('s3')
|
23
|
+
gem.add_dependency('thor')
|
24
|
+
|
19
25
|
end
|
data/lib/labs-deployer.rb
CHANGED
@@ -13,11 +13,7 @@ require 's3'
|
|
13
13
|
|
14
14
|
class Solo < Thor
|
15
15
|
|
16
|
-
#Berkshelf.load_config
|
17
16
|
Berkshelf::Config.new
|
18
|
-
AWS_ACCESS_KEY_ID = Chef::Config[:knife][:aws_access_key_id]
|
19
|
-
AWS_SECRET_ACCESS_KEY = Chef::Config[:knife][:aws_secret_access_key]
|
20
|
-
AWS_BUCKET = Chef::Config[:knife][:bucket]
|
21
17
|
|
22
18
|
desc "package", "package and deploy a cookbook"
|
23
19
|
|
@@ -31,26 +27,23 @@ class Solo < Thor
|
|
31
27
|
|
32
28
|
def get_dependencies()
|
33
29
|
say "Gathering cookbook dependencies", :green
|
34
|
-
|
35
|
-
invoke("berkshelf:install", [], path: "/tmp/
|
30
|
+
FileUtils.rm_rf("/tmp/cookbooks")
|
31
|
+
invoke("berkshelf:install", [], path: "/tmp/cookbooks", berksfile: "./Berksfile")
|
36
32
|
end
|
37
33
|
|
38
34
|
def package_files
|
39
|
-
say "Packaging cookbook", :green
|
40
|
-
`tar zcf #{get_cookbook_name}.#{get_cookbook_version}.tgz
|
41
|
-
FileUtils.mv "#{get_cookbook_name}.#{get_cookbook_version}.tgz", '/tmp'
|
35
|
+
say "== Packaging cookbook", :green
|
36
|
+
`cd /tmp; tar zcf #{get_cookbook_name}.#{get_cookbook_version}.tgz ./cookbooks`
|
42
37
|
return "/tmp/#{get_cookbook_name}.#{get_cookbook_version}.tgz"
|
43
38
|
end
|
44
39
|
|
45
40
|
def upload_cookbooks(file)
|
46
41
|
service = S3::Service.new({
|
47
|
-
:access_key_id =>
|
48
|
-
:secret_access_key =>
|
42
|
+
:access_key_id => Chef::Config[:knife][:aws_access_key_id],
|
43
|
+
:secret_access_key => Chef::Config[:knife][:aws_secret_access_key]
|
49
44
|
})
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
say "Uploading cookbook [#{file}]", :green
|
45
|
+
bucket = service.buckets.find(Chef::Config[:knife][:bucket])
|
46
|
+
say "== Uploading cookbook [#{file}]", :green
|
54
47
|
|
55
48
|
## Only upload files, we're not interested in directories
|
56
49
|
if File.file?(file)
|
@@ -59,25 +52,21 @@ class Solo < Thor
|
|
59
52
|
begin
|
60
53
|
obj = bucket.objects.find_first(remote_file)
|
61
54
|
if yes? "This cookbook version already exists, do you want to overwrite it ?", :red
|
62
|
-
say "Ok, we'll overwrite it", :green
|
55
|
+
say "== Ok, we'll overwrite it", :green
|
63
56
|
else
|
64
|
-
say "Ok, exiting", :green
|
57
|
+
say "== Ok, exiting", :green
|
65
58
|
exit 0
|
66
59
|
end
|
67
60
|
rescue
|
68
61
|
obj = nil
|
69
62
|
end
|
70
63
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
obj.save
|
78
|
-
else
|
79
|
-
say "Skipping duplicate file [ #{file} ]", :yellow
|
80
|
-
end
|
64
|
+
say "== Uploading #{file}", :green
|
65
|
+
obj = bucket.objects.build(remote_file)
|
66
|
+
obj.content = open(file)
|
67
|
+
obj.content_type = MIME::Types.type_for(file).to_s
|
68
|
+
obj.save
|
69
|
+
|
81
70
|
end
|
82
71
|
say "== Done syncing #{file.split('/')[-1]}",:green
|
83
72
|
end
|
@@ -87,7 +76,13 @@ class Solo < Thor
|
|
87
76
|
end
|
88
77
|
|
89
78
|
def get_cookbook_name
|
90
|
-
|
79
|
+
name = IO.read(Berkshelf.find_metadata).match(/^name.*/).to_s.split('"')[1]
|
80
|
+
if name.nil?
|
81
|
+
return Dir.pwd.split("/")[-1]
|
82
|
+
else
|
83
|
+
return name
|
84
|
+
end
|
85
|
+
|
91
86
|
end
|
92
87
|
|
93
88
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: labs-deployer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,8 +9,40 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-11-
|
13
|
-
dependencies:
|
12
|
+
date: 2012-11-28 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: s3
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: thor
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
14
46
|
description: Thor tasks to package chef solo cookbooks
|
15
47
|
email:
|
16
48
|
- johntdyer@gmail.com
|
@@ -40,7 +72,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
40
72
|
version: '0'
|
41
73
|
segments:
|
42
74
|
- 0
|
43
|
-
hash: -
|
75
|
+
hash: -2226089765112800771
|
44
76
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
45
77
|
none: false
|
46
78
|
requirements:
|
@@ -49,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
49
81
|
version: '0'
|
50
82
|
segments:
|
51
83
|
- 0
|
52
|
-
hash: -
|
84
|
+
hash: -2226089765112800771
|
53
85
|
requirements: []
|
54
86
|
rubyforge_project:
|
55
87
|
rubygems_version: 1.8.24
|