chef-raketasks 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +29 -1
- data/lib/chef-raketasks.rb +1 -0
- data/lib/chef/raketasks/clean.rb +4 -3
- data/lib/chef/raketasks/doc.rb +1 -0
- data/lib/chef/raketasks/gem.rb +2 -1
- data/lib/chef/raketasks/package.rb +4 -3
- data/lib/chef/raketasks/release.rb +2 -1
- data/lib/chef/raketasks/repin.rb +71 -0
- data/lib/chef/raketasks/test.rb +1 -0
- data/lib/chef/raketasks/version.rb +1 -1
- metadata +19 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de3a81f91933796f84623d88036f3a891d4f74e4194cf8f14eeac0243f382a8c
|
4
|
+
data.tar.gz: 56da97b647d22b54646b1f4f6710f553631fd48e56aa9acce23d7320bd9c7c34
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 727860aa43b68c056ee435f00b1ad31863e00e895e8a056d5c84cc2a45515a4236d3289aacd82f345424b8f8fcccdc00c1832e2839e7d178a4e2c323cb0e5bfd
|
7
|
+
data.tar.gz: 6ad1066f6eccdcbf899ae73307386a087e5626f844c15a7265b6a4482b96db4f9e157688ff9c1824efdc096944a4b91f890ea6aa2789c417f038bb82f7decc63
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -25,6 +25,9 @@ Include the Gem via ```require 'chef-raketasks'``` at the top of your
|
|
25
25
|
Rakefile. After that, just run ```rake -T``` or ```rake --tasks``` to see all
|
26
26
|
available tasks.
|
27
27
|
|
28
|
+
If you start a Rake task with parameters, please assure to not use spaces
|
29
|
+
between `[ ]`. This will result in `Don't know how to build task` errors.
|
30
|
+
|
28
31
|
## Cleanup Tasks
|
29
32
|
|
30
33
|
### rake clean:chefcache
|
@@ -109,6 +112,32 @@ It uses the current configured supermarket in your knife.rb or config.rb.
|
|
109
112
|
Upload to Chef Supermarket.
|
110
113
|
It uses the current configured supermarket in your knife.rb or config.rb.
|
111
114
|
|
115
|
+
## Repin Tasks
|
116
|
+
|
117
|
+
### rake repin:chef-client[gem,version]
|
118
|
+
|
119
|
+
Allows repinning dependencies in executables delivered with Chef Workstation.
|
120
|
+
This is often needed if you do private/prerelease builds of Chef components
|
121
|
+
like Kitchen drivers or InSpec plugins.
|
122
|
+
|
123
|
+
As the Chef installers hard-pin the versions in `/opt/chef-workstation/bin`
|
124
|
+
files, this needs the privileges to modify those files as well.
|
125
|
+
|
126
|
+
* `gem`: name of the dependency
|
127
|
+
* `version`: new version to pin
|
128
|
+
|
129
|
+
### rake repin:inspec[gem,version]
|
130
|
+
|
131
|
+
See `repin:chef-client`
|
132
|
+
|
133
|
+
### rake repin:kitchen[gem,version]
|
134
|
+
|
135
|
+
See `repin:chef-client`
|
136
|
+
|
137
|
+
### rake repin:ohai[gem,version]
|
138
|
+
|
139
|
+
See `repin:chef-client`
|
140
|
+
|
112
141
|
## Test Tasks
|
113
142
|
|
114
143
|
### rake test:integration:ec2[regexp,action]
|
@@ -168,7 +197,6 @@ specific file for this task is `.kitchen.vcenter.yml`.
|
|
168
197
|
|
169
198
|
Details at <https://github.com/chef/kitchen-vcenter>
|
170
199
|
|
171
|
-
|
172
200
|
### rake test:lint:cookbook
|
173
201
|
|
174
202
|
Run linting tests for cookbook in current dir.
|
data/lib/chef-raketasks.rb
CHANGED
@@ -24,6 +24,7 @@ require_relative 'chef/raketasks/doc'
|
|
24
24
|
require_relative 'chef/raketasks/gem'
|
25
25
|
require_relative 'chef/raketasks/package'
|
26
26
|
require_relative 'chef/raketasks/release'
|
27
|
+
require_relative 'chef/raketasks/repin'
|
27
28
|
require_relative 'chef/raketasks/test'
|
28
29
|
require_relative 'chef/raketasks/version'
|
29
30
|
|
data/lib/chef/raketasks/clean.rb
CHANGED
@@ -21,14 +21,15 @@ module ChefRake
|
|
21
21
|
include Rake::DSL if defined? Rake::DSL
|
22
22
|
class Clean < ::Rake::TaskLib
|
23
23
|
def initialize
|
24
|
+
super
|
24
25
|
|
25
26
|
namespace :clean do
|
26
27
|
desc 'Removes cache dirs from any local chef installation'
|
27
28
|
task :chefcache do
|
28
29
|
cachedirs = [
|
29
|
-
ENV['HOME']
|
30
|
-
ENV['HOME']
|
31
|
-
ENV['HOME']
|
30
|
+
File.join(ENV['HOME'], '.chef/cache'),
|
31
|
+
File.join(ENV['HOME'], '.chefdk/cache'),
|
32
|
+
File.join(ENV['HOME'], '.chef-workstation/cache')
|
32
33
|
]
|
33
34
|
cachedirs.each { |f| FileUtils.rm_rf(Dir.glob(f)) }
|
34
35
|
end
|
data/lib/chef/raketasks/doc.rb
CHANGED
data/lib/chef/raketasks/gem.rb
CHANGED
@@ -21,13 +21,14 @@ module ChefRake
|
|
21
21
|
include Rake::DSL if defined? Rake::DSL
|
22
22
|
class Gem < ::Rake::TaskLib
|
23
23
|
def initialize
|
24
|
+
super
|
24
25
|
|
25
26
|
namespace :gem do
|
26
27
|
desc 'gem:install'
|
27
28
|
namespace :install do
|
28
29
|
def install_gem(name, version, source)
|
29
30
|
cmd = 'chef gem install '
|
30
|
-
cmd << name
|
31
|
+
cmd << "#{name} "
|
31
32
|
cmd << "-v #{version} " unless version.nil?
|
32
33
|
cmd << "-s #{source} " unless source.nil?
|
33
34
|
cmd << '--no-document'
|
@@ -22,6 +22,7 @@ module ChefRake
|
|
22
22
|
include Rake::DSL if defined? Rake::DSL
|
23
23
|
class Package < ::Rake::TaskLib
|
24
24
|
def initialize
|
25
|
+
super
|
25
26
|
|
26
27
|
namespace :package do
|
27
28
|
desc 'Package cookbook as .tgz file'
|
@@ -64,13 +65,13 @@ module ChefRake
|
|
64
65
|
abs_path = File.join(current_dir, pkg_rel_path)
|
65
66
|
|
66
67
|
Dir.mkdir(pkg_path) unless Dir.exist?(pkg_path)
|
67
|
-
Dir.mkdir(ENV['HOME']
|
68
|
+
Dir.mkdir File.join(ENV['HOME'], '.inspec/cache') unless Dir.exist? File.join(ENV['HOME'], '.inspec/cache')
|
68
69
|
|
69
70
|
cmd = Train.create('local', command_runner: :generic).connection
|
70
71
|
command = 'inspec'
|
71
|
-
command <<
|
72
|
+
command << " archive #{current_dir}"
|
72
73
|
command << ' --overwrite'
|
73
|
-
command <<
|
74
|
+
command << " --output #{abs_path}"
|
74
75
|
# command << ' --vendor-cache=' + ENV['HOME'] + "/.inspec/cache" # looks like this has an error in main code
|
75
76
|
|
76
77
|
puts command
|
@@ -21,6 +21,7 @@ module ChefRake
|
|
21
21
|
include Rake::DSL if defined? Rake::DSL
|
22
22
|
class Release < ::Rake::TaskLib
|
23
23
|
def initialize
|
24
|
+
super
|
24
25
|
|
25
26
|
namespace :release do
|
26
27
|
desc 'Upload to Artifactory'
|
@@ -38,7 +39,7 @@ module ChefRake
|
|
38
39
|
require 'artifactory'
|
39
40
|
Artifactory.endpoint = args.endpoint # @TODO: Remove trailing slash, if exist
|
40
41
|
Artifactory.api_key = args.apikey
|
41
|
-
targetpath = args.path
|
42
|
+
targetpath = File.join(args.path, file_name)
|
42
43
|
|
43
44
|
artifact = Artifactory::Resource::Artifact.new(local_path: abs_path)
|
44
45
|
upload = artifact.upload(args.repokey, targetpath)
|
@@ -0,0 +1,71 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Thomas Heinen (<theinen@tecracer.de>)
|
3
|
+
# Copyright:: Copyright 2020, tecRacer Group
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
module ChefRake
|
20
|
+
module Task
|
21
|
+
include Rake::DSL if defined? Rake::DSL
|
22
|
+
class Repin < ::Rake::TaskLib
|
23
|
+
def initialize
|
24
|
+
super
|
25
|
+
|
26
|
+
namespace :repin do
|
27
|
+
desc 'Repin hard dependencies in Chef Workstation binaries'
|
28
|
+
|
29
|
+
%w[chef-client kitchen inspec ohai].each do |binary|
|
30
|
+
next unless File.exist? binary_wrapper(binary)
|
31
|
+
|
32
|
+
desc "Repin #{binary} dependency to a specific gem"
|
33
|
+
task binary.to_sym, [:gem, :version] do |_task, args|
|
34
|
+
task_repin binary, args.gem, args.version
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end # namespace repin
|
38
|
+
end # def initialize
|
39
|
+
|
40
|
+
def task_repin(name, gem, version)
|
41
|
+
read binary_wrapper(name)
|
42
|
+
repin gem, version
|
43
|
+
write_back
|
44
|
+
end
|
45
|
+
|
46
|
+
def binary_wrapper(name)
|
47
|
+
File.join('/opt/chef-workstation/bin', name)
|
48
|
+
end
|
49
|
+
|
50
|
+
def read(filename)
|
51
|
+
@contents = File.read(filename)
|
52
|
+
@filename = filename
|
53
|
+
end
|
54
|
+
|
55
|
+
def repin(gem, version)
|
56
|
+
printf("Changing version pin of %<gem>s to %<version>s for %<binary>s\n",
|
57
|
+
gem: gem,
|
58
|
+
version: version,
|
59
|
+
binary: @filename)
|
60
|
+
|
61
|
+
@contents.gsub!(/(?<=#{gem}"), "= [.0-9]+"/, ", \"= #{version}\"")
|
62
|
+
end
|
63
|
+
|
64
|
+
def write_back
|
65
|
+
File.write(@filename, @contents)
|
66
|
+
end
|
67
|
+
end # class Repin
|
68
|
+
end # module RakeTasks
|
69
|
+
end # module Chef
|
70
|
+
|
71
|
+
ChefRake::Task::Repin.new
|
data/lib/chef/raketasks/test.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chef-raketasks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patrick Schaumburg
|
8
|
+
- Thomas Heinen
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2020-
|
12
|
+
date: 2020-11-03 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: mdl
|
@@ -94,6 +95,20 @@ dependencies:
|
|
94
95
|
- - "~>"
|
95
96
|
- !ruby/object:Gem::Version
|
96
97
|
version: '3.9'
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: rubocop
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - "~>"
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '1.1'
|
105
|
+
type: :runtime
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - "~>"
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '1.1'
|
97
112
|
- !ruby/object:Gem::Dependency
|
98
113
|
name: yard
|
99
114
|
requirement: !ruby/object:Gem::Requirement
|
@@ -111,6 +126,7 @@ dependencies:
|
|
111
126
|
description: Provides a central repository of the most essential tasks
|
112
127
|
email:
|
113
128
|
- pschaumburg@tecracer.de
|
129
|
+
- theinen@tecracer.de
|
114
130
|
executables: []
|
115
131
|
extensions: []
|
116
132
|
extra_rdoc_files: []
|
@@ -123,6 +139,7 @@ files:
|
|
123
139
|
- lib/chef/raketasks/gem.rb
|
124
140
|
- lib/chef/raketasks/package.rb
|
125
141
|
- lib/chef/raketasks/release.rb
|
142
|
+
- lib/chef/raketasks/repin.rb
|
126
143
|
- lib/chef/raketasks/test.rb
|
127
144
|
- lib/chef/raketasks/version.rb
|
128
145
|
homepage: https://www.tecracer.de
|