deploy_rubygem 0.60.29 → 0.60.35

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ec76c875f88949500709195f51e3deadc201423d45165a07d7091eea4ac83af7
4
- data.tar.gz: f9ae71f8b5f2165373adae80916ef66afcfb9fd55cbaaff6a4e31ff840f0f9e7
3
+ metadata.gz: 272f1912c9321b5c99d8f3c69bee52c20ffdf8591e6e49ef82fe39f9d6e63197
4
+ data.tar.gz: c3e46c51ea5046e6a86b9b60d3a99d2c34ed577fa8e67349a8a9433f75b4569c
5
5
  SHA512:
6
- metadata.gz: 676f0eb83748ac8da940f8a6fb3183f26204bf7c639725ac79f39764c64c63b8dc82926471afe21e39d6533bd5943e02bb7f552a860a3999bd5d187339d6da72
7
- data.tar.gz: 3b0db7dc3ceb3e5ffdedf12ea975fc534748cba32fc89de9ed19b93bab97da1c25d938dbe8a57735ebd24d0441df7ceb63832794b69c7490dafb8594b739215c
6
+ metadata.gz: 02db2e27ef0d8a059d14a3faa127cf3572c768675d418e65b288887df40c35ac38a0147a26ef7d64c44220b86e63cbb3a7bd83bc43556c6955fabaff9b562bcf
7
+ data.tar.gz: 13b46eeabcf1a2d1dc7c9af1f475803ec5a3fd4021e789392b3c59f7f17ce42ca09cb979e496b2a3b67c8c43fa6059cf13590ab64d277209ac818257199df00f
checksums.yaml.gz.sig CHANGED
Binary file
data/.rubocop.yml CHANGED
@@ -25,3 +25,215 @@ Layout/CommentIndentation:
25
25
  Metrics/MethodLength:
26
26
  Enabled: true
27
27
  Max: 20
28
+
29
+ Metrics/ClassLength:
30
+ Enabled: true
31
+ Max: 102
32
+
33
+ Gemspec/DeprecatedAttributeAssignment: # new in 1.30
34
+ Enabled: true
35
+ Gemspec/DevelopmentDependencies: # new in 1.44
36
+ Enabled: true
37
+ Gemspec/RequireMFA: # new in 1.23
38
+ Enabled: false
39
+ Layout/LineContinuationLeadingSpace: # new in 1.31
40
+ Enabled: true
41
+ Layout/LineContinuationSpacing: # new in 1.31
42
+ Enabled: true
43
+ Layout/LineEndStringConcatenationIndentation: # new in 1.18
44
+ Enabled: true
45
+ Layout/SpaceBeforeBrackets: # new in 1.7
46
+ Enabled: true
47
+ Lint/AmbiguousAssignment: # new in 1.7
48
+ Enabled: true
49
+ Lint/AmbiguousOperatorPrecedence: # new in 1.21
50
+ Enabled: true
51
+ Lint/AmbiguousRange: # new in 1.19
52
+ Enabled: true
53
+ Lint/ConstantOverwrittenInRescue: # new in 1.31
54
+ Enabled: true
55
+ Lint/DeprecatedConstants: # new in 1.8
56
+ Enabled: true
57
+ Lint/DuplicateBranch: # new in 1.3
58
+ Enabled: true
59
+ Lint/DuplicateMagicComment: # new in 1.37
60
+ Enabled: true
61
+ Lint/DuplicateMatchPattern: # new in 1.50
62
+ Enabled: true
63
+ Lint/DuplicateRegexpCharacterClassElement: # new in 1.1
64
+ Enabled: true
65
+ Lint/EmptyBlock: # new in 1.1
66
+ Enabled: true
67
+ Lint/EmptyClass: # new in 1.3
68
+ Enabled: true
69
+ Lint/EmptyInPattern: # new in 1.16
70
+ Enabled: true
71
+ Lint/IncompatibleIoSelectWithFiberScheduler: # new in 1.21
72
+ Enabled: true
73
+ Lint/ItWithoutArgumentsInBlock: # new in 1.59
74
+ Enabled: true
75
+ Lint/LambdaWithoutLiteralBlock: # new in 1.8
76
+ Enabled: true
77
+ Lint/LiteralAssignmentInCondition: # new in 1.58
78
+ Enabled: true
79
+ Lint/MixedCaseRange: # new in 1.53
80
+ Enabled: true
81
+ Lint/NoReturnInBeginEndBlocks: # new in 1.2
82
+ Enabled: true
83
+ Lint/NonAtomicFileOperation: # new in 1.31
84
+ Enabled: true
85
+ Lint/NumberedParameterAssignment: # new in 1.9
86
+ Enabled: true
87
+ Lint/OrAssignmentToConstant: # new in 1.9
88
+ Enabled: true
89
+ Lint/RedundantDirGlobSort: # new in 1.8
90
+ Enabled: true
91
+ Lint/RedundantRegexpQuantifiers: # new in 1.53
92
+ Enabled: true
93
+ Lint/RefinementImportMethods: # new in 1.27
94
+ Enabled: true
95
+ Lint/RequireRangeParentheses: # new in 1.32
96
+ Enabled: true
97
+ Lint/RequireRelativeSelfPath: # new in 1.22
98
+ Enabled: true
99
+ Lint/SymbolConversion: # new in 1.9
100
+ Enabled: true
101
+ Lint/ToEnumArguments: # new in 1.1
102
+ Enabled: true
103
+ Lint/TripleQuotes: # new in 1.9
104
+ Enabled: true
105
+ Lint/UnexpectedBlockArity: # new in 1.5
106
+ Enabled: true
107
+ Lint/UnmodifiedReduceAccumulator: # new in 1.1
108
+ Enabled: true
109
+ Lint/UselessRescue: # new in 1.43
110
+ Enabled: true
111
+ Lint/UselessRuby2Keywords: # new in 1.23
112
+ Enabled: true
113
+ Metrics/CollectionLiteralLength: # new in 1.47
114
+ Enabled: true
115
+ Naming/BlockForwarding: # new in 1.24
116
+ Enabled: true
117
+ Security/CompoundHash: # new in 1.28
118
+ Enabled: true
119
+ Security/IoMethods: # new in 1.22
120
+ Enabled: true
121
+ Style/ArgumentsForwarding: # new in 1.1
122
+ Enabled: true
123
+ Style/ArrayIntersect: # new in 1.40
124
+ Enabled: true
125
+ Style/CollectionCompact: # new in 1.2
126
+ Enabled: true
127
+ Style/ComparableClamp: # new in 1.44
128
+ Enabled: true
129
+ Style/ConcatArrayLiterals: # new in 1.41
130
+ Enabled: true
131
+ Style/DataInheritance: # new in 1.49
132
+ Enabled: true
133
+ Style/DirEmpty: # new in 1.48
134
+ Enabled: true
135
+ Style/DocumentDynamicEvalDefinition: # new in 1.1
136
+ Enabled: true
137
+ Style/EmptyHeredoc: # new in 1.32
138
+ Enabled: true
139
+ Style/EndlessMethod: # new in 1.8
140
+ Enabled: true
141
+ Style/EnvHome: # new in 1.29
142
+ Enabled: true
143
+ Style/ExactRegexpMatch: # new in 1.51
144
+ Enabled: true
145
+ Style/FetchEnvVar: # new in 1.28
146
+ Enabled: true
147
+ Style/FileEmpty: # new in 1.48
148
+ Enabled: true
149
+ Style/FileRead: # new in 1.24
150
+ Enabled: true
151
+ Style/FileWrite: # new in 1.24
152
+ Enabled: true
153
+ Style/HashConversion: # new in 1.10
154
+ Enabled: true
155
+ Style/HashExcept: # new in 1.7
156
+ Enabled: true
157
+ Style/IfWithBooleanLiteralBranches: # new in 1.9
158
+ Enabled: true
159
+ Style/InPatternThen: # new in 1.16
160
+ Enabled: true
161
+ Style/MagicCommentFormat: # new in 1.35
162
+ Enabled: true
163
+ Style/MapCompactWithConditionalBlock: # new in 1.30
164
+ Enabled: true
165
+ Style/MapIntoArray: # new in 1.63
166
+ Enabled: true
167
+ Style/MapToHash: # new in 1.24
168
+ Enabled: true
169
+ Style/MapToSet: # new in 1.42
170
+ Enabled: true
171
+ Style/MinMaxComparison: # new in 1.42
172
+ Enabled: true
173
+ Style/MultilineInPatternThen: # new in 1.16
174
+ Enabled: true
175
+ Style/NegatedIfElseCondition: # new in 1.2
176
+ Enabled: true
177
+ Style/NestedFileDirname: # new in 1.26
178
+ Enabled: true
179
+ Style/NilLambda: # new in 1.3
180
+ Enabled: true
181
+ Style/NumberedParameters: # new in 1.22
182
+ Enabled: true
183
+ Style/NumberedParametersLimit: # new in 1.22
184
+ Enabled: true
185
+ Style/ObjectThen: # new in 1.28
186
+ Enabled: true
187
+ Style/OpenStructUse: # new in 1.23
188
+ Enabled: true
189
+ Style/OperatorMethodCall: # new in 1.37
190
+ Enabled: true
191
+ Style/QuotedSymbols: # new in 1.16
192
+ Enabled: true
193
+ Style/RedundantArgument: # new in 1.4
194
+ Enabled: true
195
+ Style/RedundantArrayConstructor: # new in 1.52
196
+ Enabled: true
197
+ Style/RedundantConstantBase: # new in 1.40
198
+ Enabled: true
199
+ Style/RedundantCurrentDirectoryInPath: # new in 1.53
200
+ Enabled: true
201
+ Style/RedundantDoubleSplatHashBraces: # new in 1.41
202
+ Enabled: true
203
+ Style/RedundantEach: # new in 1.38
204
+ Enabled: true
205
+ Style/RedundantFilterChain: # new in 1.52
206
+ Enabled: true
207
+ Style/RedundantHeredocDelimiterQuotes: # new in 1.45
208
+ Enabled: true
209
+ Style/RedundantInitialize: # new in 1.27
210
+ Enabled: true
211
+ Style/RedundantLineContinuation: # new in 1.49
212
+ Enabled: true
213
+ Style/RedundantRegexpArgument: # new in 1.53
214
+ Enabled: true
215
+ Style/RedundantRegexpConstructor: # new in 1.52
216
+ Enabled: true
217
+ Style/RedundantSelfAssignmentBranch: # new in 1.19
218
+ Enabled: true
219
+ Style/RedundantStringEscape: # new in 1.37
220
+ Enabled: true
221
+ Style/ReturnNilInPredicateMethodDefinition: # new in 1.53
222
+ Enabled: true
223
+ Style/SelectByRegexp: # new in 1.22
224
+ Enabled: true
225
+ Style/SendWithLiteralMethodName: # new in 1.64
226
+ Enabled: true
227
+ Style/SingleLineDoEndBlock: # new in 1.57
228
+ Enabled: true
229
+ Style/StringChars: # new in 1.12
230
+ Enabled: true
231
+ Style/SuperArguments: # new in 1.64
232
+ Enabled: true
233
+ Style/SuperWithArgsParentheses: # new in 1.58
234
+ Enabled: true
235
+ Style/SwapValues: # new in 1.1
236
+ Enabled: true
237
+ Style/YAMLFileRead: # new in 1.53
238
+ Enabled: true
239
+
data/Rakefile CHANGED
@@ -1,25 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bundler/gem_tasks'
4
- require 'rspec/core/rake_task'
5
-
6
- require 'rubocop/rake_task'
7
-
8
3
  require_relative 'lib/deploy_rubygem'
9
4
 
10
- RSpec::Core::RakeTask.new(:spec)
11
- RuboCop::RakeTask.new
12
-
13
- task test_framework: %i[clean rubocop spec]
14
- task default: %i[test_framework build install:local]
15
- task cicd: %i[default test_version]
16
- task test_version: %i[install compliance]
17
- task :compliance do
18
- system('inspec exec compliance')
19
- end
20
- task developper: %i[rubocop push default]
21
- task :push do
22
- system('git add .')
23
- system("git commit -m 'Rake pusing version #{DeployRubygem::VERSION}'")
24
- system('git push')
25
- end
5
+ DeployRubygem::RakeTask.new
@@ -1,7 +1,6 @@
1
1
  #!/opt/chef-workstation/embedded/bin/ruby
2
2
  # Signal.trap('INT') { exit 1 }
3
3
 
4
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), %w[.. lib])
5
4
  require 'rubygems' unless defined?(Gem)
6
5
  require 'deploy_rubygem'
7
6
 
data/exe/init_deploy ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ install_local
7
+ install_chef_and_bundle
8
+
9
+ install_chef_workstation
10
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bash install.sh -P chef-workstation
7
+ bundle install
8
+ rake install:local
9
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'json'
4
+
5
+ workstation_options = {
6
+ user_folder: '/root',
7
+ node_name: ENV.fetch('NODENAME'),
8
+ knife_name: ENV.fetch('KNIFE_NAME'),
9
+ policyname: ENV.fetch('POLICYNAME'),
10
+ policygroup: ENV.fetch('POLICYGROUP'),
11
+ chef_server_url: ENV.fetch('CHEF_SERVER_URL'),
12
+ chef_client_key: ENV.fetch('CHEF_CLIENT_KEY'),
13
+ chef_knife_key: ENV.fetch('CHEF_KNIFE_KEY')
14
+ }
15
+
16
+ File.write('node_options', JSON.generate(workstation_options))
17
+ system('sudo bootstrap_chef_workstation node_options')
18
+
19
+ workstation_options[:user_folder] = Dir.home
20
+ File.write('workstation_options', JSON.generate(workstation_options))
21
+ system('bootstrap_chef_workstation workstation_options')
data/exe/install_local ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+ rake build
8
+ rake install:local
9
+ curl -L https://omnitruck.chef.io/install.sh > install.sh
@@ -42,10 +42,12 @@ module DeployRubygem
42
42
  end
43
43
 
44
44
  def boostrap
45
+ extend DeployRubygem
46
+
45
47
  clientrb_file = '/etc/chef/client.rb'
46
48
  clientpem_file = '/etc/chef/client.pem'
47
49
 
48
- Dir.mkdir('/etc/chef') unless Dir.exist?('/etc/chef')
50
+ FileUtils.mkdir_p('/etc/chef')
49
51
 
50
52
  File.write(clientrb_file, clientrb)
51
53
  File.write(clientpem_file, chef_client_key.split('\\n').join("\n"))
@@ -55,7 +57,7 @@ module DeployRubygem
55
57
  # read_file(file_path)
56
58
  end
57
59
 
58
- system('chef env --chef-license accept')
60
+ system(chef_accept_cmd)
59
61
  end
60
62
  end
61
63
  end
@@ -4,6 +4,7 @@ require_relative 'project'
4
4
  require_relative 'kitchen'
5
5
  require_relative 'inspectestor'
6
6
  require_relative 'rubygem'
7
+ require_relative 'rake'
7
8
 
8
9
  # DeployRubygem - deploy a gem using rake
9
10
  # Containing a class
@@ -13,7 +14,7 @@ module DeployRubygem
13
14
  attr_reader :profiles, :kitchens, :execute_profiles
14
15
 
15
16
  def initialize(new_cookbook_info)
16
- super(new_cookbook_info)
17
+ super
17
18
  @profiles = cookbook_info[:compliance_profiles].map do |profile_name|
18
19
  input_file = File.join(%w[compliance inputs] + ["#{cookbook_name}.yml"])
19
20
  waiver_file = File.join(%w[compliance waivers] + ["#{cookbook_name}.yml"])
@@ -116,7 +117,7 @@ module DeployRubygem
116
117
 
117
118
  def save_progress
118
119
  system('git add .')
119
- system("git commit -m \"Saving: hostname=#{ENV['HOSTNAME']}, cookbook_name=#{cookbook_name}\"")
120
+ system("git commit -m \"Saving: hostname=#{ENV.fetch('HOSTNAME')}, cookbook_name=#{cookbook_name}\"")
120
121
  system('git push')
121
122
  end
122
123
 
@@ -5,7 +5,7 @@
5
5
  module DeployRubygem
6
6
  # Using Inspec to deploy and manage Inspec
7
7
  class InspecTestorResult
8
- attr_reader :success_control, :success_result, :failed_control, :failed_result, :pending_control, :pending_result
8
+ attr_reader :success_control, :success_result, :failed_control, :failed_result, :pending_control, :pending_result, :success_profiles, :failed_profiles
9
9
 
10
10
  def initialize(as_json)
11
11
  @as_json = as_json
@@ -15,6 +15,8 @@ module DeployRubygem
15
15
  @failed_result = 0
16
16
  @pending_control = 0
17
17
  @pending_result = 0
18
+ @success_profiles = []
19
+ @failed_profiles = []
18
20
  results
19
21
  end
20
22
 
@@ -43,24 +45,36 @@ module DeployRubygem
43
45
 
44
46
  private
45
47
 
48
+ def check_steps(item_result)
49
+ failed_steps = false
50
+ case item_result['status']
51
+ when 'passed'
52
+ @success_result += 1
53
+ @success_profiles << item_result['code_desc']
54
+ when 'failed'
55
+ @failed_result += 1
56
+ @failed_profiles << item_result['code_desc']
57
+ failed_steps = true
58
+ else
59
+ @pending_result += 1
60
+ @pending_control += 1
61
+ failed_steps = true
62
+ end
63
+ failed_steps
64
+ end
65
+
46
66
  def results
47
67
  controls.each do |control_result|
48
68
  control_as_fail = false
49
69
  control_result['results'].each do |item_result|
50
- case item_result['status']
51
- when 'passed'
52
- @success_result += 1
53
- when 'failed'
54
- @failed_result += 1
55
- @failed_control += 1
56
- control_as_fail = true
57
- else
58
- @pending_result += 1
59
- @pending_control += 1
60
- control_as_fail = true
61
- end
70
+ step_result = check_steps(item_result)
71
+ control_as_fail = step_result if step_result
72
+ end
73
+ if control_as_fail
74
+ @failed_control += 1
75
+ else
76
+ @success_control += 1
62
77
  end
63
- @success_control += 1 unless control_as_fail
64
78
  end
65
79
  end
66
80
  end
@@ -28,17 +28,17 @@ module DeployRubygem
28
28
  puts "waiver_file = #{waiver_file}"
29
29
 
30
30
  check
31
- system("chef inspec exec #{inspec_path} #{inspec_options.join(' ')}")
31
+ system("chef exec inspec exec #{inspec_path} #{inspec_options.join(' ')}")
32
32
  end
33
33
 
34
34
  def update
35
35
  clean
36
- system("chef inspec vendor #{inspec_path} ")
36
+ system("chef exec inspec vendor #{inspec_path} ")
37
37
  end
38
38
 
39
39
  def save_as_html(html_file)
40
40
  check
41
- system("chef inspec exec #{inspec_path} #{inspec_options.join(' ')} --reporter html:#{html_file}")
41
+ system("chef exec inspec exec #{inspec_path} #{inspec_options.join(' ')} --reporter html:#{html_file}")
42
42
  end
43
43
 
44
44
  def test_json
@@ -46,8 +46,8 @@ module DeployRubygem
46
46
  end
47
47
 
48
48
  def clean
49
- FileUtils.rm_rf(vendor_folder) if Dir.exist?(vendor_folder)
50
- File.delete(lock_file) if File.exist?(lock_file)
49
+ FileUtils.rm_rf(vendor_folder)
50
+ FileUtils.rm_f(lock_file)
51
51
  end
52
52
 
53
53
  private
@@ -0,0 +1,129 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rake/dsl_definition'
4
+
5
+ require_relative 'default'
6
+
7
+ # DeployRubygem module helper for rubygem
8
+ module DeployRubygem
9
+ # RakeTask to use with DeployRubygem projects
10
+ class RakeCookbookTask < RakeDefaultTask
11
+ def initialize(task_name = 'cookbook', desc = 'Run DeployRubygem task')
12
+ super
13
+ end
14
+
15
+ def define_tasks # :nodoc:
16
+ super
17
+ test_cookbook
18
+ release_cookbook
19
+ cookstyle
20
+ build_cookbook
21
+ install_policy
22
+ release_policy
23
+ install_cookbook
24
+ report
25
+ clean_cookbook
26
+ end
27
+
28
+ def test_framework # :nodoc:
29
+ desc "@desc with #{__method__}"
30
+ task test_framework: %i[build_cookbook spec clean_cookbook]
31
+ end
32
+
33
+ def default # :nodoc:
34
+ desc "@desc with #{__method__}"
35
+ task default: %i[test_framework build install:local]
36
+ end
37
+
38
+ def cycle # :nodoc:
39
+ desc "@desc with #{__method__}"
40
+ task cycle: %i[test_framework release_policy test_version]
41
+ end
42
+
43
+ def develop # :nodoc:
44
+ desc "@desc with #{__method__}"
45
+ task develop: %i[build_cookbook spec push install release_policy report]
46
+ end
47
+
48
+ def test_cookbook # :nodoc:
49
+ desc "@desc with #{__method__}"
50
+ task test_cookbook: %i[build_cookbook spec push install release_policy report]
51
+ end
52
+
53
+ def release_cookbook # :nodoc:
54
+ desc "@desc with #{__method__}"
55
+ task release_cookbook: %i[clean_cookbook release_policy release]
56
+ end
57
+
58
+ def cookstyle # :nodoc:
59
+ desc "@desc with #{__method__}"
60
+ task cookstyle: %i[rubocop] do
61
+ system('cookstyle')
62
+ end
63
+ end
64
+
65
+ def build_cookbook # :nodoc:
66
+ desc "@desc with #{__method__}"
67
+ task build_cookbook: %i[clean_cookbook cookstyle] do
68
+ system('knife cookbook upload jimbo_management_site')
69
+ end
70
+ end
71
+
72
+ def install_policy # :nodoc:
73
+ desc "@desc with #{__method__}"
74
+ task install_policy: %i[build_cookbook] do
75
+ system('chef install Policyfile.rb')
76
+ end
77
+ end
78
+
79
+ def release_policy # :nodoc:
80
+ desc "@desc with #{__method__}"
81
+ task release_policy: %i[clean_cookbook install_policy] do
82
+ system('chef push prod Policyfile.lock.json')
83
+ end
84
+ end
85
+
86
+ def install_cookbook # :nodoc:
87
+ desc "@desc with #{__method__}"
88
+ task :install_cookbook do
89
+ system("sudo chef-client -o #{@task_name}")
90
+ end
91
+ end
92
+
93
+ def compliance # :nodoc:
94
+ desc "@desc with #{__method__}"
95
+ task :compliance do
96
+ inspect_opts = [
97
+ '--input-file', File.join('compliance', 'inputs', "#{@task_name}.yml"),
98
+ '--waiver-file', File.join('compliance', 'waivers', "#{@task_name}.yml"),
99
+ '--reporter', "html:/tmp/html/#{@task_name}_rake_report.html"
100
+ ]
101
+ system("inspec exec compliance/profiles/#{@task_name}-accept #{inspect_opts.join(' ')}")
102
+ end
103
+ end
104
+
105
+ def report # :nodoc:
106
+ desc "@desc with #{__method__}"
107
+ task :report do
108
+ system("sudo chef-client -o #{@task_name}::compile_report")
109
+ end
110
+ end
111
+
112
+ def clean_cookbook # :nodoc:
113
+ desc "@desc with #{__method__}"
114
+ task clean_cookbook: %i[clean] do
115
+ system('kitchen destroy base')
116
+ FileUtils.rm_f('Policyfile.lock.json')
117
+ FileUtils.rm_f('Gemfile.lock')
118
+ FileUtils.rm_f('.rspec_status')
119
+ profiles_folder = File.join(%w[compliance profiles])
120
+ Dir.children(profiles_folder).each do |sub_folder|
121
+ vendor_folder = File.join(profiles_folder, sub_folder, 'vendor')
122
+ inspec_file = File.join(profiles_folder, sub_folder, 'inspec.lock')
123
+ FileUtils.rm_rf(vendor_folder)
124
+ FileUtils.rm_f(inspec_file)
125
+ end
126
+ end
127
+ end
128
+ end
129
+ end
@@ -0,0 +1,86 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rake/dsl_definition'
5
+
6
+ # DeployRubygem module helper for rubygem
7
+ module DeployRubygem
8
+ # RakeTask to use with DeployRubygem projects
9
+ class RakeDefaultTask
10
+ include ::Rake::DSL if defined?(::Rake::DSL)
11
+
12
+ # Define DeployRubygem Rake task
13
+ def initialize(task_name, desc)
14
+ @task_name = task_name
15
+ @desc = desc
16
+ yield self if block_given?
17
+ define_tasks
18
+ end
19
+
20
+ def rspec_and_rubocop
21
+ require 'rspec/core/rake_task'
22
+ require 'rubocop/rake_task'
23
+
24
+ RSpec::Core::RakeTask.new(:spec)
25
+ RuboCop::RakeTask.new
26
+ end
27
+
28
+ def define_tasks # :nodoc:
29
+ rspec_and_rubocop
30
+ test_framework
31
+ default
32
+ cycle
33
+ test_version
34
+ test_check_local
35
+ compliance
36
+ develop
37
+ push
38
+ end
39
+
40
+ def test_framework # :nodoc:
41
+ desc "@desc with #{__method__}"
42
+ task test_framework: %i[clean check_local]
43
+ end
44
+
45
+ def default # :nodoc:
46
+ desc "@desc with #{__method__}"
47
+ task default: %i[test_framework build install:local]
48
+ end
49
+
50
+ def cycle # :nodoc:
51
+ desc "@desc with #{__method__}"
52
+ task cycle: %i[default test_version]
53
+ end
54
+
55
+ def test_version # :nodoc:
56
+ desc "@desc with #{__method__}"
57
+ task test_version: %i[install compliance]
58
+ end
59
+
60
+ def test_check_local # :nodoc:
61
+ desc "@desc with #{__method__}"
62
+ task check_local: %i[rubocop spec]
63
+ end
64
+
65
+ def compliance # :nodoc:
66
+ desc "@desc with #{__method__}"
67
+ task :compliance do
68
+ system('inspec exec compliance')
69
+ end
70
+ end
71
+
72
+ def develop # :nodoc:
73
+ desc "@desc with #{__method__}"
74
+ task develop: %i[check_local clean push default]
75
+ end
76
+
77
+ def push # :nodoc:
78
+ desc "@desc with #{__method__}"
79
+ task :push do
80
+ system('git add .')
81
+ system("git commit -m 'Rake pusing version #{DeployRubygem::VERSION}'")
82
+ system('git push')
83
+ end
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rake/dsl_definition'
4
+
5
+ require_relative 'rake/cookbook'
6
+
7
+ # DeployRubygem module helper for rubygem
8
+ module DeployRubygem
9
+ # RakeTask to use with DeployRubygem projects
10
+ class RakeTask < RakeDefaultTask
11
+ def initialize(task_name = 'deploy_rubygem', desc = 'Run DeployRubygem task')
12
+ super
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ # DeployRubygem - deploy a gem using rake
4
+ # Containing a class
5
+ module DeployRubygem
6
+ def chef_env_cmd
7
+ 'chef --chef-license accept env'
8
+ end
9
+
10
+ def chef_accept_cmd
11
+ 'chef show-policy jimbo_management_site base --chef-license accept'
12
+ end
13
+
14
+ # Using Project to deploy and manage Project
15
+ module RSpecTesting
16
+ def testing_chef(chefrepo)
17
+ RSpec.describe "Accept Chef License #{chefrepo.project_name}" do
18
+ it 'Accept the Chef License' do
19
+ extend DeployRubygem
20
+ expect(`#{chef_accept_cmd}`).not_to be nil
21
+ end
22
+ end
23
+ end
24
+
25
+ def testing_workstation(chefrepo)
26
+ RSpec.describe "Install #{chefrepo.project_name}" do
27
+ it "Change to #{chefrepo} folder" do
28
+ change_repo = chefrepo.change_to_project_folder
29
+ expect(change_repo).not_to be nil
30
+ expect(Dir.pwd).to eq(chefrepo.path)
31
+ end
32
+
33
+ it 'Change to Chef repo folder' do
34
+ change_repo = chefrepo.change_to_chefrepo
35
+ expect(change_repo).not_to be nil
36
+ expect(change_repo).to eq(chefrepo.chefrepo_path)
37
+ expect(Dir.pwd).to eq(chefrepo.chefrepo_path)
38
+ end
39
+
40
+ unless chefrepo.cookbooks.nil?
41
+ it 'Should list his cookbooks dependencies' do
42
+ cookbooks = chefrepo.cookbooks
43
+ expect(cookbooks).not_to be nil
44
+ expect(cookbooks).to be_kind_of(Array)
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ # DeployRubygem - deploy a gem using rake
4
+ # Containing a class
5
+ module DeployRubygem
6
+ # Using Project to deploy and manage Project
7
+ module RSpecTesting
8
+ def testing_inspec(inspector)
9
+ inspect_test = InspecTestor.new(inspector[:inspec_path], inspector[:input_file], inspector[:waiver_file])
10
+ RSpec.describe "Testing #{inspect_test} at #{Dir.pwd}" do
11
+ it 'Should be a kind of Html' do
12
+ test_html = inspect_test.save_as_html('/tmp/html/deploy_rubygem_kind_of_html.html')
13
+ expect(test_html).to be true
14
+ end
15
+ it 'Should be a kind of Json' do
16
+ expect(inspect_test.test_json).to be_kind_of(InspecTestorResult)
17
+ expect(inspect_test.test_json.status).to eq 'loaded'
18
+ end
19
+ it 'Should be successfull' do
20
+ expect(inspect_test.test_json.success_result).to eq inspector[:success_result]
21
+ expect(inspect_test.test_json.success_control).to eq inspector[:success_control]
22
+ expect(inspect_test.test_json.failed_result).to eq inspector[:failed_result]
23
+ expect(inspect_test.test_json.failed_control).to eq inspector[:failed_control]
24
+ expect(inspect_test.test_json.pending_result).to eq inspector[:pending_result]
25
+ expect(inspect_test.test_json.pending_control).to eq inspector[:pending_control]
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ # DeployRubygem - deploy a gem using rake
4
+ # Containing a class
5
+ module DeployRubygem
6
+ # Using Project to deploy and manage Project
7
+ module RSpecTesting
8
+ def testing_gem(gem_obj)
9
+ RSpec.describe "Testing #{gem_obj}" do
10
+ it 'has a Project Name' do
11
+ expect(gem_obj.project_name).not_to be nil
12
+ end
13
+ it 'has Project Options' do
14
+ expect(gem_obj.project_options).not_to be nil
15
+ end
16
+ end
17
+ end
18
+
19
+ def install_gem_via_git(gem_obj)
20
+ RSpec.describe "Install #{gem_obj.project_name}" do
21
+ it "Change to #{gem_obj} folder" do
22
+ change_repo = gem_obj.change_to_project_folder
23
+ expect(change_repo).not_to be nil
24
+ expect(Dir.pwd).to eq(gem_obj.path)
25
+ end
26
+ end
27
+ end
28
+
29
+ def check_current_version(gem_name, version)
30
+ RSpec.describe [gem_name, version].join(', ') do
31
+ it 'has a version number' do
32
+ expect(version).not_to be nil
33
+ end
34
+
35
+ it "has not the actual version #{version} publish" do
36
+ gem_version = Gem::Version.new(version)
37
+ version_to_check = "#{gem_name} (#{gem_version})"
38
+ expect(`gem list -r #{gem_name}`).not_to include(version_to_check)
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -1,5 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative 'rspec/chef'
4
+ require_relative 'rspec/inspec'
5
+ require_relative 'rspec/ruby'
6
+
3
7
  # DeployRubygem - deploy a gem using rake
4
8
  # Containing a class
5
9
  module DeployRubygem
@@ -22,31 +26,6 @@ module DeployRubygem
22
26
  end
23
27
  end
24
28
 
25
- def check_current_version(gem_name, version)
26
- RSpec.describe gem_name do
27
- it 'has a version number' do
28
- expect(version).not_to be nil
29
- end
30
-
31
- it 'has not the actual version publish' do
32
- gem_version = Gem::Version.new(version)
33
- version_to_check = "#{gem_name} (#{gem_version})"
34
- expect(`gem list -r #{gem_name}`).not_to include(version_to_check)
35
- end
36
- end
37
- end
38
-
39
- def testing_gem(gem_obj)
40
- RSpec.describe "Testing #{gem_obj}" do
41
- it 'has a Project Name' do
42
- expect(gem_obj.project_name).not_to be nil
43
- end
44
- it 'has Project Options' do
45
- expect(gem_obj.project_options).not_to be nil
46
- end
47
- end
48
- end
49
-
50
29
  def testing_project(gem_obj)
51
30
  RSpec.describe "Testing gem #{gem_obj.project_name}" do
52
31
  it 'should not be null' do
@@ -60,62 +39,5 @@ module DeployRubygem
60
39
  end
61
40
  end
62
41
  end
63
-
64
- def testing_workstation(gem_obj)
65
- RSpec.describe "Install #{gem_obj.project_name}" do
66
- it "Change to #{gem_obj} folder" do
67
- change_repo = gem_obj.change_to_project_folder
68
- expect(change_repo).not_to be nil
69
- expect(Dir.pwd).to eq(gem_obj.path)
70
- end
71
-
72
- it 'Change to Chef repo folder' do
73
- change_repo = gem_obj.change_to_chefrepo
74
- expect(change_repo).not_to be nil
75
- expect(change_repo).to eq(gem_obj.chefrepo_path)
76
- expect(Dir.pwd).to eq(gem_obj.chefrepo_path)
77
- end
78
-
79
- unless gem_obj.cookbooks.nil?
80
- it 'Should list his cookbooks dependencies' do
81
- cookbooks = gem_obj.cookbooks
82
- expect(cookbooks).not_to be nil
83
- expect(cookbooks).to be_kind_of(Array)
84
- end
85
- end
86
- end
87
- end
88
-
89
- def install_gem_via_git(gem_obj)
90
- RSpec.describe "Install #{gem_obj.project_name}" do
91
- it "Change to #{gem_obj} folder" do
92
- change_repo = gem_obj.change_to_project_folder
93
- expect(change_repo).not_to be nil
94
- expect(Dir.pwd).to eq(gem_obj.path)
95
- end
96
- end
97
- end
98
-
99
- def testing_inspec(inspector)
100
- inspect_test = InspecTestor.new(inspector[:inspec_path], inspector[:input_file], inspector[:waiver_file])
101
- RSpec.describe "Testing #{inspect_test} at #{Dir.pwd}" do
102
- it 'Should be a kind of Html' do
103
- test_html = inspect_test.save_as_html('/tmp/html/deploy_rubygem_kind_of_html.html')
104
- expect(test_html).to be true
105
- end
106
- it 'Should be a kind of Json' do
107
- expect(inspect_test.test_json).to be_kind_of(InspecTestorResult)
108
- expect(inspect_test.test_json.status).to eq 'loaded'
109
- end
110
- it 'Should be successfull' do
111
- expect(inspect_test.test_json.success_result).to eq inspector[:success_result]
112
- expect(inspect_test.test_json.success_control).to eq inspector[:success_control]
113
- expect(inspect_test.test_json.failed_result).to eq inspector[:failed_result]
114
- expect(inspect_test.test_json.failed_control).to eq inspector[:failed_control]
115
- expect(inspect_test.test_json.pending_result).to eq inspector[:pending_result]
116
- expect(inspect_test.test_json.pending_control).to eq inspector[:pending_control]
117
- end
118
- end
119
- end
120
42
  end
121
43
  end
@@ -10,7 +10,7 @@ module DeployRubygem
10
10
  class Rubygem < Project
11
11
  def deploy_dependencies
12
12
  dependencies.each do |git_depends|
13
- Dir.chdir(::File.join(ENV['HOME'], git_depends))
13
+ Dir.chdir(::File.join(Dir.home, git_depends))
14
14
  system('git pull')
15
15
 
16
16
  system('git add .')
@@ -54,7 +54,7 @@ module DeployRubygem
54
54
  end
55
55
 
56
56
  def rake_test
57
- File.delete('Gemfile.lock') if File.exist?('Gemfile.lock')
57
+ FileUtils.rm_f('Gemfile.lock')
58
58
  system('bundle') || return
59
59
  system('bundle install') || return
60
60
  system('rake') || return
@@ -1,9 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'rubygem'
4
-
5
3
  # Set version for DeployRubygem
6
4
  module DeployRubygem
7
5
  # VERSION = new_deploy_rubygem.gvb_version.short_version
8
- VERSION = '0.60.29'
6
+ VERSION = '0.60.35'
9
7
  end
@@ -22,11 +22,11 @@ module DeployRubygem
22
22
 
23
23
  def clientrb
24
24
  {
25
- log_location: File.join(ENV['HOME'], '.chef', 'chef-client.log'),
25
+ log_location: File.join(Dir.home, '.chef', 'chef-client.log'),
26
26
  chef_server_url: chef_server_url,
27
27
  chef_license: 'accept',
28
- file_cache_path: File.join(ENV['HOME'], '.chef', 'cache'),
29
- file_backup_path: File.join(ENV['HOME'], '.chef', 'backup'),
28
+ file_cache_path: File.join(Dir.home, '.chef', 'cache'),
29
+ file_backup_path: File.join(Dir.home, '.chef', 'backup'),
30
30
  node_name: nodename,
31
31
  policy_name: policyname,
32
32
  policy_group: policygroup
@@ -55,6 +55,8 @@ module DeployRubygem
55
55
  end
56
56
 
57
57
  def boostrap_workstation
58
+ extend DeployRubygem
59
+
58
60
  knife_file = File.join(user_folder, '.chef', 'knife.rb')
59
61
  cicdpem_file = File.join(user_folder, '.chef', 'cicd.pem')
60
62
  cicdcredential_file = File.join(user_folder, '.chef', 'credentials')
@@ -70,7 +72,7 @@ module DeployRubygem
70
72
  # read_file(file_path)
71
73
  end
72
74
 
73
- system('chef env --chef-license accept')
75
+ system(chef_accept_cmd)
74
76
  end
75
77
  end
76
78
  end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'deploy_rubygem/version'
4
+ require_relative 'deploy_rubygem/rubygem'
4
5
 
5
6
  # DeployRubygem module helper for rubygem
6
7
  module DeployRubygem
@@ -11,7 +12,7 @@ module DeployRubygem
11
12
  def self.exemple_cookbook
12
13
  {
13
14
  git: 'git@git.exemple.com:/Exemple/exemple_cookbook.git',
14
- path: File.join(ENV['HOME'], 'jimbo_management_site'),
15
+ path: File.join(Dir.home, 'jimbo_management_site'),
15
16
  kitchens: %w[base],
16
17
  compliance_profiles: {
17
18
  input: 'compliance/inputs/user.yml',
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,12 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deploy_rubygem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.60.29
4
+ version: 0.60.35
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jimmy Provencher
8
8
  autorequire:
9
- bindir: bin
9
+ bindir: exe
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
@@ -33,7 +33,7 @@ cert_chain:
33
33
  n6Pwa3EckU/5n8N6gUJTAmGyu6Ncu1pbsZtH450+BJ2z82JNXomdFYlnG8+1XNlj
34
34
  3M1sBFUHvqrBg2hQkQcLHokmQYrYsRK5A7HrxwKcmwM=
35
35
  -----END CERTIFICATE-----
36
- date: 2024-06-12 00:00:00.000000000 Z
36
+ date: 2024-06-16 00:00:00.000000000 Z
37
37
  dependencies:
38
38
  - !ruby/object:Gem::Dependency
39
39
  name: rspec
@@ -112,6 +112,9 @@ email:
112
112
  executables:
113
113
  - install_chef_workstation
114
114
  - bootstrap_chef_workstation
115
+ - install_local
116
+ - install_chef_and_bundle
117
+ - init_deploy
115
118
  extensions: []
116
119
  extra_rdoc_files:
117
120
  - README.md
@@ -126,9 +129,12 @@ files:
126
129
  - LICENSE.txt
127
130
  - README.md
128
131
  - Rakefile
129
- - bin/bootstrap_chef_workstation
130
- - bin/install_chef_workstation
132
+ - exe/bootstrap_chef_workstation
131
133
  - exe/deploy_rubygem
134
+ - exe/init_deploy
135
+ - exe/install_chef_and_bundle
136
+ - exe/install_chef_workstation
137
+ - exe/install_local
132
138
  - lib/deploy_rubygem.rb
133
139
  - lib/deploy_rubygem/chef_node.rb
134
140
  - lib/deploy_rubygem/cookbook.rb
@@ -136,7 +142,13 @@ files:
136
142
  - lib/deploy_rubygem/inspectestor.rb
137
143
  - lib/deploy_rubygem/kitchen.rb
138
144
  - lib/deploy_rubygem/project.rb
145
+ - lib/deploy_rubygem/rake.rb
146
+ - lib/deploy_rubygem/rake/cookbook.rb
147
+ - lib/deploy_rubygem/rake/default.rb
139
148
  - lib/deploy_rubygem/rspec.rb
149
+ - lib/deploy_rubygem/rspec/chef.rb
150
+ - lib/deploy_rubygem/rspec/inspec.rb
151
+ - lib/deploy_rubygem/rspec/ruby.rb
140
152
  - lib/deploy_rubygem/rubygem.rb
141
153
  - lib/deploy_rubygem/testing.rb
142
154
  - lib/deploy_rubygem/version.rb
@@ -149,6 +161,7 @@ metadata:
149
161
  bug_tracker_uri: https://github.com/JimboDragonGit/deploy_rubygem/issues
150
162
  changelog_uri: https://github.com/JimboDragonGit/deploy_rubygem/releases
151
163
  homepage_uri: https://github.com/JimboDragonGit/deploy_rubygem
164
+ rubygems_mfa_required: 'true'
152
165
  post_install_message:
153
166
  rdoc_options:
154
167
  - "--charset=UTF-8"
metadata.gz.sig CHANGED
Binary file
@@ -1,24 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'json'
4
-
5
- system('curl -L https://omnitruck.chef.io/install.sh > install.sh')
6
- system('sudo bash install.sh -P chef-workstation')
7
-
8
- workstation_options = {
9
- user_folder: '/root',
10
- node_name: ENV['NODENAME'],
11
- knife_name: ENV['KNIFE_NAME'],
12
- policyname: ENV['POLICYNAME'],
13
- policygroup: ENV['POLICYGROUP'],
14
- chef_server_url: ENV['CHEF_SERVER_URL'],
15
- chef_client_key: ENV['CHEF_CLIENT_KEY'],
16
- chef_knife_key: ENV['CHEF_KNIFE_KEY']
17
- }
18
-
19
- File.write('node_options', JSON.generate(workstation_options))
20
- system('sudo bootstrap_chef_workstation node_options')
21
-
22
- workstation_options[:user_folder] = ENV['HOME']
23
- File.write('workstation_options', JSON.generate(workstation_options))
24
- system('bootstrap_chef_workstation workstation_options')