chef-zero-scheduled-task 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +14 -14
- data/Gemfile +4 -4
- data/README.md +39 -36
- data/Rakefile +52 -52
- data/chef-zero-scheduled-task.gemspec +26 -26
- data/lib/chef/zero/scheduled/task/version.rb +1 -1
- data/lib/kitchen/provisioner/chef_zero_scheduled_task.rb +50 -37
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3a4cd8ee79e0008cbec419edba9ab0eca46e606
|
4
|
+
data.tar.gz: 2f7f988aba5c1835148fe0aa4a991b2131ed6d89
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e15314dd568e10e277df4fc2d29bcf8787f867414e96f1eaef481b0a9a4f1e2c935fb4d59aa334ce339b02d221c6a2c08009bc2dee592dd2569f389a4e7e3088
|
7
|
+
data.tar.gz: 90b9cc3af97d42cb5b6f8914c37ec5df39b42442291c4311ba02757337821387106c36c0208fd235b327d685bba2b1fe445f760a296f1acfa980104ad71916fa
|
data/.gitignore
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
/.bundle/
|
2
|
-
/.yardoc
|
3
|
-
/Gemfile.lock
|
4
|
-
/_yardoc/
|
5
|
-
/coverage/
|
6
|
-
/doc/
|
7
|
-
/pkg/
|
8
|
-
/spec/reports/
|
9
|
-
/tmp/
|
10
|
-
*.bundle
|
11
|
-
*.so
|
12
|
-
*.o
|
13
|
-
*.a
|
14
|
-
mkmf.log
|
1
|
+
/.bundle/
|
2
|
+
/.yardoc
|
3
|
+
/Gemfile.lock
|
4
|
+
/_yardoc/
|
5
|
+
/coverage/
|
6
|
+
/doc/
|
7
|
+
/pkg/
|
8
|
+
/spec/reports/
|
9
|
+
/tmp/
|
10
|
+
*.bundle
|
11
|
+
*.so
|
12
|
+
*.o
|
13
|
+
*.a
|
14
|
+
mkmf.log
|
data/Gemfile
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
|
3
|
-
# Specify your gem's dependencies in chef-zero-scheduled-task.gemspec
|
4
|
-
gemspec
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in chef-zero-scheduled-task.gemspec
|
4
|
+
gemspec
|
data/README.md
CHANGED
@@ -1,36 +1,39 @@
|
|
1
|
-
[![Gem Version](https://badge.fury.io/rb/chef-zero-scheduled-task.svg)](http://badge.fury.io/rb/chef-zero-scheduled-task)
|
2
|
-
# Chef::Zero::Scheduled::Task
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
```
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
1
|
+
[![Gem Version](https://badge.fury.io/rb/chef-zero-scheduled-task.svg)](http://badge.fury.io/rb/chef-zero-scheduled-task)
|
2
|
+
# Chef::Zero::Scheduled::Task
|
3
|
+
|
4
|
+
## Installation
|
5
|
+
|
6
|
+
Add this line to your application's Gemfile:
|
7
|
+
|
8
|
+
```ruby
|
9
|
+
gem 'chef-zero-scheduled-task'
|
10
|
+
```
|
11
|
+
|
12
|
+
And then execute:
|
13
|
+
|
14
|
+
$ bundle
|
15
|
+
|
16
|
+
Or install it yourself as:
|
17
|
+
|
18
|
+
$ gem install chef-zero-scheduled-task
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
|
22
|
+
In the .kitchen.yml
|
23
|
+
```
|
24
|
+
provisioner:
|
25
|
+
name: chef_zero_scheduled_task
|
26
|
+
```
|
27
|
+
|
28
|
+
This provisioner uses all the same configuration options as the native chef-zero provisioner, as well as:
|
29
|
+
|
30
|
+
* task_username - user account the scheduled task should run under. (defaults to the username used for the transport)
|
31
|
+
* task_password - password to use to create the scheduled task. (defaults to the password used for the transport)
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
1. Fork it ( https://github.com/[my-github-username]/chef-zero-scheduled-task/fork )
|
36
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
37
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
38
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
39
|
+
5. Create a new Pull Request
|
data/Rakefile
CHANGED
@@ -1,52 +1,52 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
require "bundler/gem_tasks"
|
4
|
-
|
5
|
-
require "rake/testtask"
|
6
|
-
Rake::TestTask.new(:unit) do |t|
|
7
|
-
t.libs.push "lib"
|
8
|
-
t.test_files = FileList["spec/**/*_spec.rb"]
|
9
|
-
t.verbose = true
|
10
|
-
end
|
11
|
-
|
12
|
-
desc "Run all test suites"
|
13
|
-
task :test => [:unit]
|
14
|
-
|
15
|
-
desc "Display LOC stats"
|
16
|
-
task :stats do
|
17
|
-
puts "\n## Production Code Stats"
|
18
|
-
sh "countloc -r lib"
|
19
|
-
puts "\n## Test Code Stats"
|
20
|
-
sh "countloc -r spec"
|
21
|
-
end
|
22
|
-
|
23
|
-
require "finstyle"
|
24
|
-
require "rubocop/rake_task"
|
25
|
-
RuboCop::RakeTask.new(:style) do |task|
|
26
|
-
task.options << "--display-cop-names"
|
27
|
-
task.options << "--lint"
|
28
|
-
task.options << '--config' << '.rubocop.yml'
|
29
|
-
task.patterns = ['lib/**/*.rb']
|
30
|
-
end
|
31
|
-
|
32
|
-
require "cane/rake_task"
|
33
|
-
desc "Run cane to check quality metrics"
|
34
|
-
Cane::RakeTask.new do |cane|
|
35
|
-
cane.canefile = "./.cane"
|
36
|
-
end
|
37
|
-
|
38
|
-
desc "Run all quality tasks"
|
39
|
-
task :quality => [:cane, :style, :stats]
|
40
|
-
|
41
|
-
require "yard"
|
42
|
-
YARD::Rake::YardocTask.new
|
43
|
-
|
44
|
-
desc "Generate gem dependency graph"
|
45
|
-
task :viz do
|
46
|
-
Bundler.with_clean_env do
|
47
|
-
sh "bundle viz --without test development guard " \
|
48
|
-
"--requirements --version"
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
task :default => [:test, :quality]
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
|
5
|
+
require "rake/testtask"
|
6
|
+
Rake::TestTask.new(:unit) do |t|
|
7
|
+
t.libs.push "lib"
|
8
|
+
t.test_files = FileList["spec/**/*_spec.rb"]
|
9
|
+
t.verbose = true
|
10
|
+
end
|
11
|
+
|
12
|
+
desc "Run all test suites"
|
13
|
+
task :test => [:unit]
|
14
|
+
|
15
|
+
desc "Display LOC stats"
|
16
|
+
task :stats do
|
17
|
+
puts "\n## Production Code Stats"
|
18
|
+
sh "countloc -r lib"
|
19
|
+
puts "\n## Test Code Stats"
|
20
|
+
sh "countloc -r spec"
|
21
|
+
end
|
22
|
+
|
23
|
+
require "finstyle"
|
24
|
+
require "rubocop/rake_task"
|
25
|
+
RuboCop::RakeTask.new(:style) do |task|
|
26
|
+
task.options << "--display-cop-names"
|
27
|
+
task.options << "--lint"
|
28
|
+
task.options << '--config' << '.rubocop.yml'
|
29
|
+
task.patterns = ['lib/**/*.rb']
|
30
|
+
end
|
31
|
+
|
32
|
+
require "cane/rake_task"
|
33
|
+
desc "Run cane to check quality metrics"
|
34
|
+
Cane::RakeTask.new do |cane|
|
35
|
+
cane.canefile = "./.cane"
|
36
|
+
end
|
37
|
+
|
38
|
+
desc "Run all quality tasks"
|
39
|
+
task :quality => [:cane, :style, :stats]
|
40
|
+
|
41
|
+
require "yard"
|
42
|
+
YARD::Rake::YardocTask.new
|
43
|
+
|
44
|
+
desc "Generate gem dependency graph"
|
45
|
+
task :viz do
|
46
|
+
Bundler.with_clean_env do
|
47
|
+
sh "bundle viz --without test development guard " \
|
48
|
+
"--requirements --version"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
task :default => [:test, :quality]
|
@@ -1,26 +1,26 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'chef/zero/scheduled/task/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = "chef-zero-scheduled-task"
|
8
|
-
spec.version = Chef::Zero::Scheduled::Task::VERSION
|
9
|
-
spec.authors = ["Steven Murawski"]
|
10
|
-
spec.email = ["steven.murawski@gmail.com"]
|
11
|
-
spec.summary = "Test-Kitchen Provisioner that runs Chef Zero in a Scheduled Task"
|
12
|
-
spec.description = "Test-Kitchen Provisioner that runs Chef Zero in a Scheduled Task"
|
13
|
-
spec.homepage = "https://github.com/smurawski/chef-zero-scheduled-task"
|
14
|
-
spec.license = "Apache 2"
|
15
|
-
|
16
|
-
spec.files = `git ls-files -z`.split("\x0")
|
17
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = ["lib"]
|
20
|
-
|
21
|
-
spec.add_development_dependency "bundler", "~> 1.7"
|
22
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
-
spec.add_development_dependency "pry", "~> 0.10"
|
24
|
-
|
25
|
-
spec.add_dependency "test-kitchen", "~> 1.4"
|
26
|
-
end
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'chef/zero/scheduled/task/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "chef-zero-scheduled-task"
|
8
|
+
spec.version = Chef::Zero::Scheduled::Task::VERSION
|
9
|
+
spec.authors = ["Steven Murawski"]
|
10
|
+
spec.email = ["steven.murawski@gmail.com"]
|
11
|
+
spec.summary = "Test-Kitchen Provisioner that runs Chef Zero in a Scheduled Task"
|
12
|
+
spec.description = "Test-Kitchen Provisioner that runs Chef Zero in a Scheduled Task"
|
13
|
+
spec.homepage = "https://github.com/smurawski/chef-zero-scheduled-task"
|
14
|
+
spec.license = "Apache 2"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency "pry", "~> 0.10"
|
24
|
+
|
25
|
+
spec.add_dependency "test-kitchen", "~> 1.4"
|
26
|
+
end
|
@@ -16,19 +16,20 @@
|
|
16
16
|
# See the License for the specific language governing permissions and
|
17
17
|
# limitations under the License.
|
18
18
|
|
19
|
-
require
|
19
|
+
require 'kitchen/provisioner/chef_zero'
|
20
20
|
|
21
21
|
module Kitchen
|
22
|
-
|
23
22
|
module Provisioner
|
24
|
-
|
25
23
|
# Chef Zero provisioner to run in scheduled task on Windows
|
26
24
|
class ChefZeroScheduledTask < ChefZero
|
27
|
-
|
28
25
|
kitchen_provisioner_api_version 2
|
29
26
|
|
30
27
|
plugin_version Kitchen::VERSION
|
31
28
|
|
29
|
+
default_config :task_username
|
30
|
+
|
31
|
+
default_config :task_password
|
32
|
+
|
32
33
|
def create_sandbox
|
33
34
|
super
|
34
35
|
return unless windows_os?
|
@@ -37,30 +38,37 @@ module Kitchen
|
|
37
38
|
|
38
39
|
def init_command
|
39
40
|
resolve_username_and_password
|
40
|
-
wrap_shell_code(
|
41
|
-
$cmd_path = "#{remote_path_join(config[:root_path], "chef-client-script.ps1")}"
|
42
|
-
$cmd_line = $executioncontext.invokecommand.expandstring("powershell -executionpolicy unrestricted -File $cmd_path")
|
43
|
-
schtasks /create /tn "chef-tk" /ru #{@task_username} /rp #{@task_password} /sc daily /st 00:00 /f /tr "$cmd_line"
|
44
|
-
EOH
|
45
|
-
)
|
41
|
+
wrap_shell_code(setup_scheduled_task_command)
|
46
42
|
end
|
47
43
|
|
48
|
-
#assuming a version of Chef with local mode.
|
44
|
+
# assuming a version of Chef with local mode.
|
49
45
|
def prepare_command
|
50
46
|
return unless windows_os?
|
51
47
|
info('Creating a script to run chef client.')
|
52
|
-
|
53
|
-
$pre_cmd = "`$env:temp = `"$env:temp`""
|
54
|
-
$cmd_path = "#{remote_path_join(config[:root_path], "chef-client-script.ps1")}"
|
55
|
-
$cmd_to_eval = gc $cmd_path | out-string
|
56
|
-
$cmd = $executioncontext.invokecommand.expandstring($cmd_to_eval)
|
57
|
-
$pre_cmd, $cmd | out-file $cmd_path
|
58
|
-
EOH
|
59
|
-
wrap_shell_code(cmd)
|
48
|
+
wrap_shell_code(scheduled_task_command)
|
60
49
|
end
|
61
50
|
|
62
51
|
def run_command
|
63
|
-
wrap_shell_code(
|
52
|
+
wrap_shell_code(run_scheduled_task_command)
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
def resolve_username_and_password
|
58
|
+
unless config[:task_username] && config[:task_password]
|
59
|
+
local_state_file = @instance.diagnose[:state_file]
|
60
|
+
if local_state_file.key?(:password)
|
61
|
+
config[:task_username] = local_state_file[:username]
|
62
|
+
config[:task_password] = local_state_file[:password]
|
63
|
+
else
|
64
|
+
config[:task_username] = @instance.transport[:username]
|
65
|
+
config[:task_password] = @instance.transport[:password]
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def run_scheduled_task_command
|
71
|
+
<<-EOH
|
64
72
|
if (test-path 'c:/chef/tk.log') {
|
65
73
|
remove-item c:/chef/tk.log -force
|
66
74
|
}
|
@@ -74,25 +82,30 @@ module Kitchen
|
|
74
82
|
$host.ui.WriteLine('')
|
75
83
|
get-content c:/chef/tk.log -readcount 0
|
76
84
|
EOH
|
77
|
-
)
|
78
85
|
end
|
79
86
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
else
|
88
|
-
@task_username = @instance.transport[:username]
|
89
|
-
@task_password = @instance.transport[:password]
|
90
|
-
end
|
87
|
+
def setup_scheduled_task_command
|
88
|
+
<<-EOH
|
89
|
+
$cmd_path = "#{remote_path_join(config[:root_path], 'chef-client-script.ps1')}"
|
90
|
+
$cmd_line = $executioncontext.invokecommand.expandstring("powershell -executionpolicy unrestricted -File $cmd_path")
|
91
|
+
schtasks /create /tn "chef-tk" /ru #{config[:task_username]} /rp #{config[:task_password]} /sc daily /st 00:00 /f /tr "$cmd_line"
|
92
|
+
EOH
|
93
|
+
end
|
91
94
|
|
95
|
+
def scheduled_task_command
|
96
|
+
<<-EOH
|
97
|
+
$pre_cmd = '$env:temp = "' + $env:temp + '"'
|
98
|
+
$cmd_path = "#{remote_path_join(config[:root_path], 'chef-client-script.ps1')}"
|
99
|
+
$cmd_to_eval = gc $cmd_path | out-string
|
100
|
+
$cmd = $executioncontext.invokecommand.expandstring($cmd_to_eval)
|
101
|
+
$cmd_folder = split-path $cmd_path
|
102
|
+
if (-not (test-path $cmd_folder)) {$null = mkdir $cmd_folder}
|
103
|
+
$pre_cmd, $cmd | out-file $cmd_path
|
104
|
+
EOH
|
92
105
|
end
|
93
106
|
|
94
107
|
def prepare_client_zero_script
|
95
|
-
cmd = [local_mode_command, *chef_client_args, '--logfile c:\chef\tk.log'].join(
|
108
|
+
cmd = [local_mode_command, *chef_client_args, '--logfile c:\chef\tk.log'].join(' ')
|
96
109
|
File.open(File.join(sandbox_path, 'chef-client-script.ps1'), 'w') do |file|
|
97
110
|
file.write(cmd)
|
98
111
|
end
|
@@ -101,10 +114,10 @@ module Kitchen
|
|
101
114
|
def chef_client_args
|
102
115
|
level = config[:log_level] == :info ? :info : config[:log_level]
|
103
116
|
args = [
|
104
|
-
"--config #{remote_path_join(config[:root_path],
|
117
|
+
"--config #{remote_path_join(config[:root_path], 'client.rb')}",
|
105
118
|
"--log_level #{level}",
|
106
|
-
|
107
|
-
|
119
|
+
'--force-formatter',
|
120
|
+
'--no-color'
|
108
121
|
]
|
109
122
|
add_optional_chef_client_args!(args)
|
110
123
|
|
@@ -112,4 +125,4 @@ module Kitchen
|
|
112
125
|
end
|
113
126
|
end
|
114
127
|
end
|
115
|
-
end
|
128
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chef-zero-scheduled-task
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steven Murawski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|