chef-zero-scheduled-task 0.1.0 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8f3acb420f410d9de9998ce1f84dd1d5d5bcf5f8
4
- data.tar.gz: 50e9cd3b55afc6e3f9b8173cb2311e60c72f58ad
3
+ metadata.gz: 608601471764f4e51c89d85f9461d17bb9792bde
4
+ data.tar.gz: d037970d8f12c554a9d7e8b41996b7c4628a3a45
5
5
  SHA512:
6
- metadata.gz: ee8f18aa97189e76f91cbe126c3d52969e941c7ee3279c8285a8137b5654008cf5136b320769ad5439ec6388adce7b957aaf231242bd7360fec5de37d558ddb5
7
- data.tar.gz: a51c76a51764c6fe3c6f8934613d55676a8314170565d1c270e891a72c47a8a4f01af2705f6f0be4f05ecea96d54a4284f6488537f206fa68bb853a12ac36a57
6
+ metadata.gz: 461d755d1b78cef6a6e1fd83e44d3c5358fdb2c78643b850ad5edb7626f67896e23d5a15c62e615f975d04aebe1471335195e03ac2d7cf023655ef3b76ca752b
7
+ data.tar.gz: 3c6efb7589f0a35619c18768ee37881928dac2fffaec2f75865ba2ef1d95affefd2c82d3dab9ddc47ac8b2a8d40ed1df9ae42c7ca9e2b79262a735e77a43cd51
data/README.md CHANGED
@@ -1,39 +1,5 @@
1
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
2
 
4
- ## Installation
3
+ # Deprecated!
5
4
 
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
5
+ This project has been deprecated in favor of the scheduled task support built in to the WinRM transport in Test-Kitchen v1.8 or newer.
@@ -19,10 +19,9 @@ Gem::Specification.new do |spec|
19
19
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
20
  spec.require_paths = ["lib"]
21
21
 
22
- spec.add_dependency "test-kitchen", "~> 1.4"
22
+ spec.add_dependency "test-kitchen", "~> 1.8"
23
23
 
24
24
  spec.add_development_dependency "pry"
25
- spec.add_development_dependency "winrm-transport", "~> 1.0"
26
25
 
27
26
  spec.add_development_dependency "bundler", "~> 1.3"
28
27
  spec.add_development_dependency "rake"
@@ -2,7 +2,7 @@ module Chef
2
2
  module Zero
3
3
  module Scheduled
4
4
  module Task
5
- VERSION = "0.1.0"
5
+ VERSION = "0.2.0"
6
6
  end
7
7
  end
8
8
  end
@@ -25,151 +25,15 @@ module Kitchen
25
25
  kitchen_provisioner_api_version 2
26
26
 
27
27
  plugin_version Kitchen::VERSION
28
-
29
- default_config :task_username
30
-
31
- default_config :task_password
32
-
33
- def init_command
34
- if windows_os?
35
- info("Creating the scheduled task.")
36
- wrap_shell_code("#{super}\n#{setup_scheduled_task_command}")
37
- else
38
- super
39
- end
40
- end
41
-
42
- def run_command
43
- if windows_os?
44
- script = <<-EOH
45
- $script = @'\n#{scheduled_task_command_script}\n'@
46
- $ExecutionContext.InvokeCommand.ExpandString($Script) |
47
- out-file "$env:temp/kitchen/chef-client-script.ps1"
48
- #{run_scheduled_task_command}
49
- EOH
50
- wrap_shell_code(script)
51
- else
52
- super
53
- end
54
- end
55
-
56
- # private
57
-
58
- def local_state_file
59
- @local_state_file ||= @instance.diagnose[:state_file]
60
- end
61
-
62
- def task_username
63
- if config[:task_username]
64
- config[:task_username]
65
- else
66
- if local_state_file.key?(:username)
67
- local_state_file[:username]
68
- else
69
- @instance.transport[:username]
70
- end
71
- end
72
- end
73
-
74
- def task_password
75
- unless config[:task_password]
76
- if local_state_file.key?(:password)
77
- local_state_file[:password]
78
- else
79
- @instance.transport[:password]
80
- end
81
- end
82
- end
83
-
84
- # rubocop:disable MethodLength
85
- def run_scheduled_task_command
86
- <<-EOH
87
- try {
88
- Add-Type -AssemblyName System.Core
89
- $npipeServer = new-object System.IO.Pipes.NamedPipeServerStream('task',
90
- [System.IO.Pipes.PipeDirection]::In)
91
- $pipeReader = new-object System.IO.StreamReader($npipeServer)
92
- schtasks /run /tn "chef-tk" /i
93
- $npipeserver.waitforconnection()
94
- $host.ui.writeline('Connected to the scheduled task.')
95
- while ($npipeserver.IsConnected) {
96
- $output = $pipereader.ReadLine()
97
- if ($output -like 'SCHEDULED_TASK_DONE:*') {
98
- $exit_code = ($output -replace 'SCHEDULED_TASK_DONE:').trim()
99
- }
100
- else { $host.ui.WriteLine($output) } } }
101
- finally {
102
- $pipereader.dispose()
103
- $npipeserver.dispose()
104
- $host.setshouldexit($exit_code)
105
- }
106
- EOH
107
- end
108
- # rubocop:enable MethodLength
109
-
110
- def new_scheduled_task_command
111
- "schtasks /create /tn 'chef-tk' " \
112
- "/ru '#{task_username}' /rp '#{task_password}' " \
113
- "/sc daily /st 00:00 /rl HIGHEST /f "
114
- end
115
-
116
- def new_scheduled_task_command_line_ps
117
- "/tr $executioncontext.invokecommand.expandstring(" \
118
- '"powershell -executionpolicy unrestricted -File '
119
- end
120
-
121
- def setup_scheduled_task_command
122
- new_scheduled_task_command +
123
- new_scheduled_task_command_line_ps +
124
- remote_chef_client_script +
125
- '")'
126
- end
127
-
128
- def remote_chef_client_script
129
- @remote_script_path ||= remote_path_join(
130
- config[:root_path], "chef-client-script.ps1")
131
- end
132
-
133
- def scheduled_task_command_script
134
- <<-EOH
135
- Add-Type -AssemblyName System.Core
136
- start-sleep -seconds 5;
137
- `$npipeClient = new-object System.IO.Pipes.NamedPipeClientStream(`$env:ComputerName,
138
- `'task`', [System.IO.Pipes.PipeDirection]::Out);
139
- `$npipeclient.connect();
140
- `$pipeWriter = new-object System.IO.StreamWriter(`$npipeClient);
141
- `$pipeWriter.AutoFlush = `$true;
142
- #{client_zero_command} |
143
- foreach-object {} {`$pipewriter.writeline(`$_)} {
144
- `$pipewriter.writeline("SCHEDULED_TASK_DONE: `$LastExitCode");
145
- `$pipewriter.dispose();
146
- `$npipeclient.dispose()
147
- }
148
- EOH
149
- end
150
-
151
- def prepare_client_zero_script
152
- File.open(File.join(sandbox_path, "chef-client-script.ps1"), "w") do |file|
153
- file.write(Util.outdent!(scheduled_task_command_script))
154
- end
155
- end
156
-
157
- def client_zero_command
158
- [local_mode_command, *chef_client_args].join(" ")
159
- end
160
-
161
- def chef_client_args
162
- level = config[:log_level] == :info ? :info : config[:log_level]
163
- args = [
164
- "--config #{remote_path_join(config[:root_path], "client.rb")}",
165
- "--log_level #{level}",
166
- "--force-formatter",
167
- "--no-color"
168
- ]
169
- add_optional_chef_client_args!(args)
170
-
171
- args
172
- end
28
+
29
+ def install_command
30
+ warn "This provisioner has been deprecated."
31
+ warn "This is will run the default ChefZero provisioner."
32
+ warn "The WinRM transport in Test-Kitchen 1.8 or newer now supports using scheduled tasks to run commands."
33
+ warn "To execute this in a scheduled task, `elvated:true` in the transport configuration."
34
+ super
35
+ end
36
+
173
37
  end
174
38
  end
175
39
  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.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Murawski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-02 00:00:00.000000000 Z
11
+ date: 2016-05-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: test-kitchen
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.4'
19
+ version: '1.8'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.4'
26
+ version: '1.8'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: pry
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -38,20 +38,6 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: winrm-transport
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '1.0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '1.0'
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: bundler
57
43
  requirement: !ruby/object:Gem::Requirement
@@ -259,7 +245,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
259
245
  version: '0'
260
246
  requirements: []
261
247
  rubyforge_project:
262
- rubygems_version: 2.5.2
248
+ rubygems_version: 2.6.4
263
249
  signing_key:
264
250
  specification_version: 4
265
251
  summary: Test-Kitchen Provisioner that runs Chef Zero in a Scheduled Task