Skip to content

Commit 4c5f2bc

Browse files
ehelmsevgeni
authored andcommitted
Add certs command
Signed-off-by: Eric D. Helms <[email protected]>
1 parent 55c6d3d commit 4c5f2bc

File tree

5 files changed

+94
-2
lines changed

5 files changed

+94
-2
lines changed

.packit.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ upstream_tag_template: "{version}"
1717

1818
actions:
1919
post-upstream-clone:
20-
- "wget https://raw.githubusercontent.com/theforeman/foreman-packaging/rpm/develop/packages/foreman/foreman-installer/foreman-installer.spec -O foreman-installer.spec"
20+
- "wget https://raw.githubusercontent.com/evgeni/foreman-packaging/ansible-installer/packages/foreman/foreman-installer/foreman-installer.spec -O foreman-installer.spec"
2121
get-current-version:
2222
- "sed 's/-develop//' VERSION"
2323
create-archive:

Rakefile

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,11 @@ task :modules => "#{BUILDDIR}/modules"
3737
if BUILD_KATELLO
3838
SCENARIOS = ['foreman', 'foreman-proxy-content', 'katello'].freeze
3939
CERTS_SCENARIOS = ['foreman-proxy-certs'].freeze
40+
NEW_CERTS_SCENARIOS = ['foreman-certs'].freeze
4041
else
4142
SCENARIOS = ['foreman'].freeze
4243
CERTS_SCENARIOS = [].freeze
44+
NEW_CERTS_SCENARIOS = [].freeze
4345
end
4446

4547
exporter_dirs = ENV['PATH'].split(':').push('/usr/bin', ENV['KAFO_EXPORTER'])
@@ -136,6 +138,33 @@ CERTS_SCENARIOS.each do |scenario|
136138
end
137139
end
138140

141+
NEW_CERTS_SCENARIOS.each do |scenario|
142+
config = "foreman_certs/config/#{scenario}.yaml"
143+
file "#{BUILDDIR}/#{scenario}.yaml" => [config, BUILDDIR] do |t|
144+
cp t.prerequisites.first, t.name
145+
146+
scenario_config_replacements = {
147+
'answer_file' => "#{DATADIR}/foreman-installer/foreman-certs/scenarios.d/#{scenario}-answers.yaml",
148+
'installer_dir' => "#{DATADIR}/foreman-installer/foreman-certs",
149+
'log_dir' => "#{LOGDIR}/foreman-installer",
150+
'module_dirs' => "#{DATADIR}/foreman-installer/modules",
151+
'parser_cache_path' => "#{DATADIR}/foreman-installer/parser_cache/#{scenario}.yaml",
152+
}
153+
154+
scenario_config_replacements.each do |setting, value|
155+
sh format('sed -i "s#\(.*%s:\).*#\1 %s#" %s', setting, value, t.name)
156+
end
157+
end
158+
159+
file "#{BUILDDIR}/parser_cache/#{scenario}.yaml" => [config, "#{BUILDDIR}/modules", "#{BUILDDIR}/parser_cache"] do |t|
160+
sh "#{exporter}/kafo-export-params -c #{t.prerequisites.first} -f parsercache --no-parser-cache -o #{t.name}"
161+
end
162+
163+
file "#{BUILDDIR}/#{scenario}-options.asciidoc" => [config, "#{BUILDDIR}/parser_cache/#{scenario}.yaml"] do |t|
164+
sh "#{exporter}/kafo-export-params -c #{t.prerequisites.first} -f asciidoc -o #{t.name}"
165+
end
166+
end
167+
139168
file "#{BUILDDIR}/foreman-installer" => 'bin/foreman-installer' do |t|
140169
cp t.prerequisites[0], t.name
141170
sh format('sed -i "s#\(^.*CONFIG_DIR = \).*#CONFIG_DIR = %s#" %s', "'#{SYSCONFDIR}/foreman-installer/scenarios.d/'", t.name)
@@ -146,6 +175,11 @@ file "#{BUILDDIR}/foreman-proxy-certs-generate" => 'bin/foreman-proxy-certs-gene
146175
sh format('sed -i "s#^.*\(CONFIG_DIR = \).*#\1%s#" %s', "'#{DATADIR}/foreman-installer/katello-certs/scenarios.d/'", t.name)
147176
end
148177

178+
file "#{BUILDDIR}/foreman-certs" => 'bin/foreman-certs' do |t|
179+
cp t.prerequisites[0], t.name
180+
sh format('sed -i "s#^.*\(CONFIG_DIR = \).*#\1%s#" %s', "'#{DATADIR}/foreman-installer/foreman-certs/scenarios.d/'", t.name)
181+
end
182+
149183
file "#{BUILDDIR}/katello-certs-check" => 'bin/katello-certs-check' do |t|
150184
cp t.prerequisites[0], t.name
151185
end
@@ -211,6 +245,7 @@ namespace :build do
211245

212246
if BUILD_KATELLO
213247
task :base => [
248+
"#{BUILDDIR}/foreman-certs",
214249
"#{BUILDDIR}/foreman-proxy-certs-generate",
215250
"#{BUILDDIR}/katello-certs-check",
216251
]
@@ -234,9 +269,16 @@ namespace :build do
234269
"#{BUILDDIR}/parser_cache/#{scenario}.yaml",
235270
]
236271
end].flatten
272+
273+
task :new_certs_scenarios => [NEW_CERTS_SCENARIOS.map do |scenario|
274+
[
275+
"#{BUILDDIR}/#{scenario}.yaml",
276+
"#{BUILDDIR}/parser_cache/#{scenario}.yaml",
277+
]
278+
end].flatten
237279
end
238280

239-
task :build => ['build:base', 'build:scenarios', 'build:certs_scenarios']
281+
task :build => ['build:base', 'build:scenarios', 'build:certs_scenarios', 'build:new_certs_scenarios']
240282

241283
task :install => :build do
242284
mkdir_p "#{DATADIR}/foreman-installer"
@@ -261,6 +303,14 @@ task :install => :build do
261303
cp "katello_certs/config/#{scenario}-answers.yaml", "#{DATADIR}/foreman-installer/katello-certs/scenarios.d/#{scenario}-answers.yaml"
262304
end
263305

306+
if NEW_CERTS_SCENARIOS.any?
307+
mkdir_p "#{DATADIR}/foreman-installer/foreman-certs/scenarios.d"
308+
end
309+
NEW_CERTS_SCENARIOS.each do |scenario|
310+
cp "#{BUILDDIR}/#{scenario}.yaml", "#{DATADIR}/foreman-installer/foreman-certs/scenarios.d/#{scenario}.yaml"
311+
cp "foreman_certs/config/#{scenario}-answers.yaml", "#{DATADIR}/foreman-installer/foreman-certs/scenarios.d/#{scenario}-answers.yaml"
312+
end
313+
264314
cp_r "#{BUILDDIR}/modules", "#{DATADIR}/foreman-installer", :preserve => true
265315
cp_r "#{BUILDDIR}/parser_cache", "#{DATADIR}/foreman-installer"
266316

@@ -271,6 +321,7 @@ task :install => :build do
271321
install "#{BUILDDIR}/foreman-installer", "#{SBINDIR}/foreman-installer", :mode => 0o755, :verbose => true
272322

273323
if BUILD_KATELLO
324+
install "#{BUILDDIR}/foreman-certs", "#{SBINDIR}/foreman-certs", :mode => 0o755, :verbose => true
274325
install "#{BUILDDIR}/foreman-proxy-certs-generate", "#{SBINDIR}/foreman-proxy-certs-generate", :mode => 0o755, :verbose => true
275326
install "#{BUILDDIR}/katello-certs-check", "#{SBINDIR}/katello-certs-check", :mode => 0o755, :verbose => true
276327
end

bin/foreman-certs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env ruby
2+
require 'rubygems'
3+
require 'kafo'
4+
5+
CONFIG_DIR = './foreman_certs/config/'.freeze
6+
7+
@result = Kafo::KafoConfigure.run
8+
exit((@result.nil? || @result.exit_code == 2) ? 0 : @result.exit_code)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
certs:
2+
generate: true
3+
regenerate: true
4+
deploy: false
5+
group: root
6+
certs::generate: true
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
:answer_file: "./foreman_certs/config/foreman-certs-answers.yaml"
3+
:color_of_background: :dark
4+
:colors: true
5+
:custom: {}
6+
:description: Generate Foreman certificates
7+
:dont_save_answers: true
8+
:enabled: true
9+
:facts: {}
10+
:hook_dirs: []
11+
:installer_dir: "./foreman_certs"
12+
:log_dir: "./_build/"
13+
:log_level: :debug
14+
:log_name: foreman-certs.log
15+
:low_priority_modules: []
16+
:mapping: {}
17+
:module_dirs: "./_build/modules"
18+
:name: foreman-certs
19+
:no_prefix: true
20+
:order:
21+
- certs
22+
- certs:generate
23+
:parser_cache_path: "./_build/parser_cache/foreman-certs.yaml"
24+
:skip_puppet_version_check: false
25+
:store_dir: ''
26+
:verbose: false
27+
:verbose_log_level: debug

0 commit comments

Comments
 (0)