chef-fork 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/chef-fork.gemspec +2 -3
- data/lib/chef/fork/application.rb +5 -2
- data/lib/chef/fork/commands.rb +13 -1
- data/lib/chef/fork/commands/bootstrap.rb +14 -4
- data/lib/chef/fork/commands/cookbook.rb +1 -1
- data/lib/chef/fork/commands/data.rb +1 -1
- data/lib/chef/fork/commands/databag.rb +1 -1
- data/lib/chef/fork/commands/environment.rb +1 -1
- data/lib/chef/fork/commands/help.rb +2 -1
- data/lib/chef/fork/commands/node.rb +2 -2
- data/lib/chef/fork/commands/role.rb +1 -1
- data/lib/chef/fork/commands/ssh.rb +2 -1
- data/lib/chef/fork/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d17a69329759230186ad22f20d0351e83064065
|
4
|
+
data.tar.gz: 735fc1a41ec02e208324b378f582b5d00daae28a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 336ca8301cb1f474636ac53aabd33fd66f6d9b21e9720137b4961a199176a836ebb8675e16bb915f9fa2760f9fa569684d3ba553922cacca1f45bf8fa6417d7f
|
7
|
+
data.tar.gz: 6586ba56251e95643770a1fd50be7efb974067b947aff31f3641394a6388cb8cd94a38190ea916a24b079a2e9f4811df7315e9372d38f005c1566524c1d8d088
|
data/chef-fork.gemspec
CHANGED
@@ -8,15 +8,14 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = Chef::Fork::VERSION
|
9
9
|
spec.authors = ["Yamashita Yuu"]
|
10
10
|
spec.email = ["peek824545201@gmail.com"]
|
11
|
-
|
12
11
|
spec.summary = %q{A tool for your left hand, to have a meal cooked by chef.}
|
13
12
|
spec.description = %q{A tool for your left hand, to have a meal cooked by chef.}
|
14
13
|
spec.homepage = "https://github.com/yyuu/chef-fork"
|
15
14
|
spec.license = "Apache-2.0"
|
16
15
|
|
17
16
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
-
spec.
|
19
|
-
spec.
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
19
|
spec.require_paths = ["lib"]
|
21
20
|
|
22
21
|
spec.add_development_dependency "bundler", "~> 1.9"
|
@@ -21,7 +21,6 @@ class Chef
|
|
21
21
|
attr_reader :optparse
|
22
22
|
|
23
23
|
def main(args=[])
|
24
|
-
configure_chef(locate_config_file("fork") || locate_config_file("knife"))
|
25
24
|
rest = @optparse.order(args)
|
26
25
|
begin
|
27
26
|
command = get_command(rest.shift || "help").new(self)
|
@@ -31,6 +30,10 @@ class Chef
|
|
31
30
|
end
|
32
31
|
end
|
33
32
|
|
33
|
+
def configure(options={})
|
34
|
+
configure_chef(locate_config_file("fork") || locate_config_file("knife"), options)
|
35
|
+
end
|
36
|
+
|
34
37
|
private
|
35
38
|
def define_options()
|
36
39
|
options.merge!({
|
@@ -98,7 +101,7 @@ class Chef
|
|
98
101
|
end
|
99
102
|
end
|
100
103
|
|
101
|
-
def configure_chef(config_file)
|
104
|
+
def configure_chef(config_file, options={})
|
102
105
|
if config_file
|
103
106
|
@logger.info("Using configuration from #{config_file}")
|
104
107
|
Chef::Config.from_file(config_file)
|
data/lib/chef/fork/commands.rb
CHANGED
@@ -13,7 +13,7 @@ class Chef
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def run(args=[])
|
16
|
-
|
16
|
+
order_args(args=[])
|
17
17
|
end
|
18
18
|
|
19
19
|
private
|
@@ -30,6 +30,18 @@ class Chef
|
|
30
30
|
@application.optparse
|
31
31
|
end
|
32
32
|
|
33
|
+
def order_args(args=[])
|
34
|
+
args = @application.optparse.order(args)
|
35
|
+
@application.configure(@application.options)
|
36
|
+
args
|
37
|
+
end
|
38
|
+
|
39
|
+
def parse_args(args=[])
|
40
|
+
args = @application.optparse.parse(args)
|
41
|
+
@application.configure(@application.options)
|
42
|
+
args
|
43
|
+
end
|
44
|
+
|
33
45
|
def rest()
|
34
46
|
@rest ||= Chef::REST.new(Chef::Config[:chef_server_url])
|
35
47
|
end
|
@@ -13,7 +13,7 @@ class Chef
|
|
13
13
|
module Commands
|
14
14
|
class Bootstrap < Ssh
|
15
15
|
def run(args=[])
|
16
|
-
rest =
|
16
|
+
rest = parse_args(args)
|
17
17
|
if hostname = rest.shift
|
18
18
|
command = bootstrap_command()
|
19
19
|
ssh(hostname, [command])
|
@@ -75,14 +75,24 @@ class Chef
|
|
75
75
|
template_file = options[:template_file] || find_template(options[:distro])
|
76
76
|
if template_file
|
77
77
|
template = File.read(template_file)
|
78
|
-
render_template(template)
|
78
|
+
command = render_template(template)
|
79
|
+
if options[:use_sudo]
|
80
|
+
"sudo #{command}"
|
81
|
+
else
|
82
|
+
command
|
83
|
+
end
|
79
84
|
else
|
80
|
-
raise(NameError.new("Unknown distro: #{distro.inspect}"))
|
85
|
+
raise(NameError.new("Unknown distro: #{options[:distro].inspect}"))
|
81
86
|
end
|
82
87
|
end
|
83
88
|
|
84
89
|
def find_template(name)
|
85
|
-
templates = $LOAD_PATH.map { |path|
|
90
|
+
templates = $LOAD_PATH.map { |path|
|
91
|
+
[
|
92
|
+
File.join(path, "chef", "knife", "bootstrap", "templates", "#{name}.erb"), # Chef 12.x
|
93
|
+
File.join(path, "chef", "knife", "bootstrap", "#{name}.erb"), # Chef 11.x
|
94
|
+
]
|
95
|
+
}.reduce(:+)
|
86
96
|
templates.find { |path| File.exist?(path) }
|
87
97
|
end
|
88
98
|
|
@@ -10,7 +10,7 @@ class Chef
|
|
10
10
|
module Commands
|
11
11
|
class Node < Noop
|
12
12
|
def run(args=[])
|
13
|
-
rest =
|
13
|
+
rest = order_args(args)
|
14
14
|
case rest.first
|
15
15
|
when "edit"
|
16
16
|
node_edit(rest.slice(1..-1) || [])
|
@@ -19,7 +19,7 @@ class Chef
|
|
19
19
|
when "show"
|
20
20
|
node_show(rest.slice(1..-1) || [])
|
21
21
|
else
|
22
|
-
raise(NameError.new(
|
22
|
+
raise(NameError.new(@args.inspect))
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
data/lib/chef/fork/version.rb
CHANGED
metadata
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chef-fork
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yamashita Yuu
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
date: 2015-06-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
@@ -69,7 +69,8 @@ dependencies:
|
|
69
69
|
description: A tool for your left hand, to have a meal cooked by chef.
|
70
70
|
email:
|
71
71
|
- peek824545201@gmail.com
|
72
|
-
executables:
|
72
|
+
executables:
|
73
|
+
- fork
|
73
74
|
extensions: []
|
74
75
|
extra_rdoc_files: []
|
75
76
|
files:
|