chef-sandwich 0.3.0 → 0.4.0
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 +7 -0
- data/LICENSE +1 -1
- data/NEWS +10 -0
- data/Rakefile +4 -6
- data/bin/sandwich +1 -1
- data/lib/sandwich/cli.rb +22 -1
- data/lib/sandwich/client.rb +5 -2
- data/lib/sandwich/cookbook_version.rb +8 -2
- data/lib/sandwich/runner.rb +3 -2
- data/lib/sandwich/version.rb +1 -1
- data/spec/runner_spec.rb +16 -11
- data/spec/spec_helper.rb +37 -9
- metadata +83 -79
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 2282901c2af027ce54b89570e6269cee00718f61
|
|
4
|
+
data.tar.gz: 0ed0efbb3a04ae19a624539858513216584a3a36
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: e2d7d054dd49575b162a4881545e5b84e5bda8b1b0c3fc1152d8634821137eef62e133ede86cc568f89a82ad1d436ddc6442564d7235a29a602f92fbcadc8a20
|
|
7
|
+
data.tar.gz: 2b282f8d93c970e9ed15d2f8a97d65573cc182cac244070cab009fb8b91bfed2f9c6f2a7fb0c94e85db5b1168c2eb9157a8c54e226d14c5634dd2e30e065a94a
|
data/LICENSE
CHANGED
|
@@ -187,7 +187,7 @@
|
|
|
187
187
|
same "printed page" as the copyright notice for easier
|
|
188
188
|
identification within third-party archives.
|
|
189
189
|
|
|
190
|
-
Copyright 2011 Sebastian Boehm
|
|
190
|
+
Copyright 2011-2015 Sebastian Boehm
|
|
191
191
|
|
|
192
192
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
193
|
you may not use this file except in compliance with the License.
|
data/NEWS
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
* sandwich NEWS
|
|
2
|
+
** 0.4.0 (2015-01-18)
|
|
3
|
+
|
|
4
|
+
- Naotoshi Seo
|
|
5
|
+
- Fix uninitialized constant Sandwich::Client::UUIDTools
|
|
6
|
+
- Fix uninitialized constant Chef::Application
|
|
7
|
+
- Support segment_filenames
|
|
8
|
+
- Add --json-attributes option
|
|
9
|
+
- Support --why-run mode
|
|
10
|
+
- Enhance error message shown by sandwich command
|
|
11
|
+
|
|
2
12
|
** 0.3.0 (2011-10-17)
|
|
3
13
|
|
|
4
14
|
- Add -e option
|
data/Rakefile
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
require 'rake/testtask'
|
|
2
|
+
require 'sandwich/version'
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
sh 'gem build chef-sandwich.gemspec'
|
|
7
|
-
end
|
|
4
|
+
desc "Build chef-sandwich-#{Sandwich::VERSION}.gem"
|
|
5
|
+
task :gem do
|
|
6
|
+
sh 'gem build chef-sandwich.gemspec'
|
|
8
7
|
end
|
|
9
8
|
|
|
10
9
|
Rake::TestTask.new do |t|
|
|
11
10
|
t.pattern = 'spec/*_spec.rb'
|
|
12
|
-
t.verbose = false
|
|
13
11
|
end
|
data/bin/sandwich
CHANGED
data/lib/sandwich/cli.rb
CHANGED
|
@@ -43,6 +43,18 @@ module Sandwich
|
|
|
43
43
|
'Execute command as a sandwich script') do |c|
|
|
44
44
|
@options[:command] << c
|
|
45
45
|
end
|
|
46
|
+
|
|
47
|
+
opts.on('-W',
|
|
48
|
+
'--why-run',
|
|
49
|
+
'Enable whyrun mode') do
|
|
50
|
+
@options[:why_run] = true
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
opts.on('-j',
|
|
54
|
+
'--json-attributes JSON_ATTRIBS',
|
|
55
|
+
'Load attributes from a JSON file or URL') do |c|
|
|
56
|
+
@options[:json_attribs] = c
|
|
57
|
+
end
|
|
46
58
|
end
|
|
47
59
|
end
|
|
48
60
|
|
|
@@ -70,10 +82,19 @@ module Sandwich
|
|
|
70
82
|
end
|
|
71
83
|
end
|
|
72
84
|
|
|
85
|
+
if @options[:why_run]
|
|
86
|
+
Chef::Config[:why_run] = true
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
if @options[:json_attribs]
|
|
90
|
+
config_fetcher = Chef::ConfigFetcher.new(@options[:json_attribs])
|
|
91
|
+
json_attribs = config_fetcher.fetch_json
|
|
92
|
+
end
|
|
93
|
+
|
|
73
94
|
# pass remaining arguments on to script
|
|
74
95
|
ARGV.replace(unparsed_arguments)
|
|
75
96
|
|
|
76
|
-
runner = Sandwich::Runner.new(recipe_filename, recipe)
|
|
97
|
+
runner = Sandwich::Runner.new(recipe_filename, recipe, json_attribs)
|
|
77
98
|
runner.run(@options[:log_level])
|
|
78
99
|
end
|
|
79
100
|
end
|
data/lib/sandwich/client.rb
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
require 'sandwich/cookbook_version'
|
|
2
2
|
require 'chef'
|
|
3
|
+
require 'uuidtools'
|
|
4
|
+
require 'chef/application'
|
|
3
5
|
|
|
4
6
|
module Sandwich
|
|
5
7
|
# Chef::Client extended to inject a Sandwich cookbook into the
|
|
@@ -13,9 +15,10 @@ module Sandwich
|
|
|
13
15
|
#
|
|
14
16
|
# @param [String] recipe_filename the recipe filename
|
|
15
17
|
# @param [String] recipe_string the recipe definition
|
|
16
|
-
|
|
18
|
+
# @param [Hash] json_attribs the JSON attributes
|
|
19
|
+
def initialize(recipe_filename, recipe_string = nil, json_attribs = nil)
|
|
17
20
|
Chef::Config[:solo] = true
|
|
18
|
-
super()
|
|
21
|
+
super(json_attribs)
|
|
19
22
|
|
|
20
23
|
if recipe_string
|
|
21
24
|
@sandwich_basedir = Dir.getwd
|
|
@@ -24,8 +24,14 @@ module Sandwich
|
|
|
24
24
|
segment,
|
|
25
25
|
filename,
|
|
26
26
|
current_filepath=nil)
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
segment_filenames = [
|
|
28
|
+
File.join(segment.to_s, "#{node[:platform]}-#{node[:platform_version]}", filename),
|
|
29
|
+
File.join(segment.to_s, node[:platform], filename),
|
|
30
|
+
File.join(segment.to_s, 'default', filename),
|
|
31
|
+
File.join(segment.to_s, filename),
|
|
32
|
+
File.expand_path(filename, @basedir), # keep absolute paths, convert relative paths into absolute paths
|
|
33
|
+
]
|
|
34
|
+
segment_filenames.find {|filename| File.exist?(filename) }
|
|
29
35
|
end
|
|
30
36
|
end
|
|
31
37
|
end
|
data/lib/sandwich/runner.rb
CHANGED
|
@@ -14,8 +14,9 @@ module Sandwich
|
|
|
14
14
|
#
|
|
15
15
|
# @param [String] recipe_filename the recipe filename
|
|
16
16
|
# @param [String] recipe_string the recipe definition
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
# @param [Hash] json_attribs the JSON attributes
|
|
18
|
+
def initialize(recipe_filename, recipe_string = nil, json_attribs = nil)
|
|
19
|
+
@client = Sandwich::Client.new(recipe_filename, recipe_string, json_attribs)
|
|
19
20
|
end
|
|
20
21
|
|
|
21
22
|
# Run Chef in standalone mode, apply recipe
|
data/lib/sandwich/version.rb
CHANGED
data/spec/runner_spec.rb
CHANGED
|
@@ -17,17 +17,6 @@ describe Sandwich::Runner do
|
|
|
17
17
|
file.must_equal content
|
|
18
18
|
end
|
|
19
19
|
end
|
|
20
|
-
|
|
21
|
-
it 'should throw exceptions for files in missing directories' do
|
|
22
|
-
with_fakefs do
|
|
23
|
-
filename = '/i/am/not/here'
|
|
24
|
-
content = 'hello world'
|
|
25
|
-
recipe = %Q(file '#{filename}' do content '#{content}';end)
|
|
26
|
-
run = Proc.new { run_recipe recipe }
|
|
27
|
-
run.must_raise(Errno::ENOENT,
|
|
28
|
-
Chef::Exceptions::EnclosingDirectoryDoesNotExist)
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
20
|
end
|
|
32
21
|
|
|
33
22
|
describe Chef::Resource::CookbookFile do
|
|
@@ -45,6 +34,22 @@ describe Sandwich::Runner do
|
|
|
45
34
|
end
|
|
46
35
|
end
|
|
47
36
|
|
|
37
|
+
describe Chef::Resource::Template do
|
|
38
|
+
it 'should create templates' do
|
|
39
|
+
with_fakefs do
|
|
40
|
+
source = '/source.erb'
|
|
41
|
+
target = '/target'
|
|
42
|
+
content = 'hello <%= node[:hostname] %>'
|
|
43
|
+
recipe = %Q(template '#{target}' do source '/source.erb';end)
|
|
44
|
+
# create source template
|
|
45
|
+
File.open(source, 'w') { |f| f.write(content) }
|
|
46
|
+
run_recipe(recipe)
|
|
47
|
+
hostname = ohai_data(:hostname)
|
|
48
|
+
File.read(target).must_equal "hello #{hostname}"
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
48
53
|
describe Chef::Resource::Directory do
|
|
49
54
|
it 'should create directories' do
|
|
50
55
|
with_fakefs do
|
data/spec/spec_helper.rb
CHANGED
|
@@ -16,11 +16,10 @@ class Ohai::System
|
|
|
16
16
|
end
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
end
|
|
19
|
+
def ohai_data(key)
|
|
20
|
+
ohai = Ohai::System.new
|
|
21
|
+
ohai.all_plugins
|
|
22
|
+
ohai.data[key]
|
|
24
23
|
end
|
|
25
24
|
|
|
26
25
|
def runner_from_recipe(recipe)
|
|
@@ -31,17 +30,46 @@ def run_recipe(recipe)
|
|
|
31
30
|
runner_from_recipe(recipe).run(:fatal)
|
|
32
31
|
end
|
|
33
32
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
# fakefs does not support IO.binread (which is used a lot by chef),
|
|
34
|
+
# therefore monkey patch IO.binread to use FakeFS::File.binread
|
|
35
|
+
def with_fake_io_binread
|
|
36
|
+
IO.instance_eval do
|
|
37
|
+
alias :binread_orig :binread
|
|
38
|
+
def self.binread(path); FakeFS::File.binread(path); end
|
|
39
|
+
end
|
|
37
40
|
yield
|
|
38
41
|
ensure
|
|
39
|
-
|
|
42
|
+
IO.instance_eval { alias :binread :binread_orig }
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def with_fakefs
|
|
46
|
+
FakeFS do
|
|
47
|
+
setup_standard_dirs
|
|
48
|
+
with_fake_io_binread { yield }
|
|
49
|
+
end
|
|
40
50
|
end
|
|
41
51
|
|
|
42
52
|
def setup_standard_dirs
|
|
43
53
|
FileUtils.mkdir_p '/tmp'
|
|
54
|
+
FileUtils.mkdir_p Chef::Config[:file_cache_path]
|
|
44
55
|
end
|
|
45
56
|
|
|
46
57
|
# make sure Chef 0.10 exceptions are available when using older Chef versions
|
|
47
58
|
class Chef::Exceptions::EnclosingDirectoryDoesNotExist; end
|
|
59
|
+
|
|
60
|
+
Chef::Config[:client_fork] = false
|
|
61
|
+
Chef::Config[:force_logger] = true
|
|
62
|
+
|
|
63
|
+
# FakeFS does not provide File.realpath, but for our simple tests
|
|
64
|
+
# expand_path is close enough
|
|
65
|
+
class FakeFS::File
|
|
66
|
+
def self.realpath(*args)
|
|
67
|
+
expand_path(*args)
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# disable Chef run locks
|
|
72
|
+
class Chef::RunLock
|
|
73
|
+
def test; true; end
|
|
74
|
+
def save_pid; end
|
|
75
|
+
end
|
metadata
CHANGED
|
@@ -1,85 +1,94 @@
|
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: chef-sandwich
|
|
3
|
-
version: !ruby/object:Gem::Version
|
|
4
|
-
|
|
5
|
-
version: 0.3.0
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.4.0
|
|
6
5
|
platform: ruby
|
|
7
|
-
authors:
|
|
6
|
+
authors:
|
|
8
7
|
- Sebastian Boehm
|
|
9
8
|
autorequire:
|
|
10
9
|
bindir: bin
|
|
11
10
|
cert_chain: []
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
dependencies:
|
|
16
|
-
- !ruby/object:Gem::Dependency
|
|
11
|
+
date: 2015-01-19 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
17
14
|
name: chef
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
- !ruby/object:Gem::Version
|
|
24
|
-
version: "0.9"
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ~>
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: 11.12.8
|
|
25
20
|
type: :runtime
|
|
26
|
-
version_requirements: *id001
|
|
27
|
-
- !ruby/object:Gem::Dependency
|
|
28
|
-
name: uuidtools
|
|
29
21
|
prerelease: false
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ~>
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: 11.12.8
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: uuidtools
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ~>
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: 2.1.5
|
|
36
34
|
type: :runtime
|
|
37
|
-
version_requirements: *id002
|
|
38
|
-
- !ruby/object:Gem::Dependency
|
|
39
|
-
name: minitest
|
|
40
35
|
prerelease: false
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ~>
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: 2.1.5
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: minitest
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ~>
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: 5.5.1
|
|
47
48
|
type: :development
|
|
48
|
-
version_requirements: *id003
|
|
49
|
-
- !ruby/object:Gem::Dependency
|
|
50
|
-
name: fakefs
|
|
51
49
|
prerelease: false
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - ~>
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: 5.5.1
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: fakefs
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ~>
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: 0.6.4
|
|
58
62
|
type: :development
|
|
59
|
-
version_requirements: *id004
|
|
60
|
-
- !ruby/object:Gem::Dependency
|
|
61
|
-
name: rake
|
|
62
63
|
prerelease: false
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
requirements:
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
66
|
- - ~>
|
|
67
|
-
- !ruby/object:Gem::Version
|
|
68
|
-
version: 0.
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: 0.6.4
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: rake
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ~>
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: 10.4.2
|
|
69
76
|
type: :development
|
|
70
|
-
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - ~>
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: 10.4.2
|
|
71
83
|
description: |
|
|
72
84
|
Sandwich lets you apply Chef recipes to your system without having to
|
|
73
85
|
worry about cookbooks or configuration.
|
|
74
|
-
|
|
75
86
|
email: sebastian@sometimesfood.org
|
|
76
|
-
executables:
|
|
87
|
+
executables:
|
|
77
88
|
- sandwich
|
|
78
89
|
extensions: []
|
|
79
|
-
|
|
80
90
|
extra_rdoc_files: []
|
|
81
|
-
|
|
82
|
-
files:
|
|
91
|
+
files:
|
|
83
92
|
- Rakefile
|
|
84
93
|
- README.md
|
|
85
94
|
- LICENSE
|
|
@@ -94,33 +103,28 @@ files:
|
|
|
94
103
|
- lib/sandwich.rb
|
|
95
104
|
- spec/runner_spec.rb
|
|
96
105
|
- spec/spec_helper.rb
|
|
97
|
-
has_rdoc: true
|
|
98
106
|
homepage: https://github.com/sometimesfood/sandwich
|
|
99
|
-
licenses:
|
|
100
|
-
|
|
107
|
+
licenses:
|
|
108
|
+
- Apache License (2.0)
|
|
109
|
+
metadata: {}
|
|
101
110
|
post_install_message:
|
|
102
111
|
rdoc_options: []
|
|
103
|
-
|
|
104
|
-
require_paths:
|
|
112
|
+
require_paths:
|
|
105
113
|
- lib
|
|
106
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
- !ruby/object:Gem::Version
|
|
117
|
-
version: "0"
|
|
114
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
115
|
+
requirements:
|
|
116
|
+
- - '>='
|
|
117
|
+
- !ruby/object:Gem::Version
|
|
118
|
+
version: '0'
|
|
119
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
|
+
requirements:
|
|
121
|
+
- - '>='
|
|
122
|
+
- !ruby/object:Gem::Version
|
|
123
|
+
version: '0'
|
|
118
124
|
requirements: []
|
|
119
|
-
|
|
120
125
|
rubyforge_project:
|
|
121
|
-
rubygems_version:
|
|
126
|
+
rubygems_version: 2.0.14
|
|
122
127
|
signing_key:
|
|
123
|
-
specification_version:
|
|
128
|
+
specification_version: 4
|
|
124
129
|
summary: The easiest way to get started as a chef
|
|
125
130
|
test_files: []
|
|
126
|
-
|