smart_proxy_ansible_director 0.6.0 → 0.7.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 +4 -4
- data/lib/smart_proxy_ansible_director/actions/meta/build_push_ee.rb +31 -35
- data/lib/smart_proxy_ansible_director/actions/meta/run_ansible_script.rb +1 -1
- data/lib/smart_proxy_ansible_director/actions/meta/run_playbook.rb +20 -10
- data/lib/smart_proxy_ansible_director/plugin.rb +41 -3
- data/lib/smart_proxy_ansible_director/runners/ansible_builder_runner.rb +11 -11
- data/lib/smart_proxy_ansible_director/runners/ansible_navigator_runner.rb +26 -27
- data/lib/smart_proxy_ansible_director/runners/meta_runner.rb +10 -13
- data/lib/smart_proxy_ansible_director/runners/podman_pull_runner.rb +5 -1
- data/lib/smart_proxy_ansible_director/runners/podman_push_runner.rb +8 -8
- data/lib/smart_proxy_ansible_director/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ecd7bca9499c92013e47ab4de68b7172c2f1d0d37a89d4b6f5de7b5319bc0405
|
|
4
|
+
data.tar.gz: d389d6b6cad1752b5f80efe3cfd6ee6ac2c2a61a7f03231a0b86a44d015ae77d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1497f6db7412a154f434f5be05be800e6fb1560b7be43df7013eb01b2682cfc244fc4889feaa0ee8b85cb78e0349da62321a70d5c80f553b1498d5883edfc747
|
|
7
|
+
data.tar.gz: 2176d249b9d1501b4618aef64d3a416b6a9fe21482122bafba8b5bd6a2406aff326ea45966d862560e5feb62ad5b2d6943a2fd035b50c9679e5c27d4517a9d66
|
|
@@ -3,58 +3,54 @@
|
|
|
3
3
|
require_relative '../build_execution_environment'
|
|
4
4
|
require_relative '../push_execution_environment'
|
|
5
5
|
require_relative '../../helpers/execution_environment_helpers'
|
|
6
|
+
require_relative '../../runners/ansible_builder_runner'
|
|
7
|
+
require_relative '../../runners/podman_push_runner'
|
|
8
|
+
require_relative '../../runners/meta_runner'
|
|
6
9
|
|
|
7
10
|
module Proxy
|
|
8
11
|
module AnsibleDirector
|
|
9
12
|
module Actions
|
|
10
13
|
module Meta
|
|
11
14
|
class BuildPushEe < ::Proxy::Dynflow::Action::Runner
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
# }
|
|
25
|
-
# ]
|
|
26
|
-
# }
|
|
27
|
-
# }
|
|
28
|
-
# }
|
|
29
|
-
def plan(args)
|
|
30
|
-
execution_environment_definition = args['execution_environment']
|
|
15
|
+
RUNNER_PHASES = [
|
|
16
|
+
{ id: :build_ee, title: 'Building Execution Environment',
|
|
17
|
+
runner_class: ::Proxy::AnsibleDirector::Runners::AnsibleBuilderRunner,
|
|
18
|
+
runner_input_key: :build_ee_input },
|
|
19
|
+
{ id: :push_ee, title: 'Pushing Execution Environment',
|
|
20
|
+
runner_class: ::Proxy::AnsibleDirector::Runners::PodmanPushRunner,
|
|
21
|
+
runner_input_key: :push_ee_input }
|
|
22
|
+
].freeze
|
|
23
|
+
|
|
24
|
+
def initiate_runner
|
|
25
|
+
execution_environment_definition = input['execution_environment']
|
|
26
|
+
push_url = input['push_url']
|
|
31
27
|
|
|
32
28
|
ee_id = execution_environment_definition['id']
|
|
33
29
|
execution_environment_content = execution_environment_definition['content']
|
|
34
30
|
|
|
35
31
|
ee_base_image = execution_environment_content['base_image']
|
|
36
|
-
ee_base_image_tag =
|
|
32
|
+
ee_base_image_tag = push_url
|
|
37
33
|
ee_ansible_core_version = execution_environment_content['ansible_core_version']
|
|
38
34
|
ee_formatted_content = ::Proxy::AnsibleDirector::Helpers::ExecutionEnvironmentHelpers.format_content(
|
|
39
35
|
execution_environment_content['content_units']
|
|
40
36
|
)
|
|
41
37
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
38
|
+
::Proxy::AnsibleDirector::Runners::MetaRunner.new(
|
|
39
|
+
RUNNER_PHASES,
|
|
40
|
+
{
|
|
41
|
+
build_ee_input: {
|
|
42
|
+
ee_id: ee_id,
|
|
43
|
+
ee_base_image_url: ee_base_image,
|
|
44
|
+
ee_built_image_tag: ee_base_image_tag,
|
|
45
|
+
ee_ansible_core_version: ee_ansible_core_version,
|
|
46
|
+
ee_formatted_content: ee_formatted_content,
|
|
47
|
+
is_base_image: true
|
|
48
|
+
},
|
|
49
|
+
push_ee_input: {
|
|
50
|
+
push_url: push_url
|
|
51
|
+
}
|
|
50
52
|
}
|
|
51
|
-
|
|
52
|
-
# Registry authorization has not been finalized.
|
|
53
|
-
# Further, granular capability usage is difficult with the current execution stack.
|
|
54
|
-
# plan_action ::Proxy::AnsibleDirector::Actions::PushExecutionEnvironment, {
|
|
55
|
-
# ee_id: ee_id
|
|
56
|
-
# }
|
|
57
|
-
end
|
|
53
|
+
)
|
|
58
54
|
end
|
|
59
55
|
end
|
|
60
56
|
end
|
|
@@ -21,7 +21,7 @@ module Proxy
|
|
|
21
21
|
mode: 'literal',
|
|
22
22
|
inventory: inventory,
|
|
23
23
|
playbook: script,
|
|
24
|
-
execution_environment:
|
|
24
|
+
execution_environment: execution_environment
|
|
25
25
|
}
|
|
26
26
|
plan_action ::Proxy::Dynflow::Callback::Action,
|
|
27
27
|
args[:callback],
|
|
@@ -3,35 +3,46 @@
|
|
|
3
3
|
require_relative '../build_execution_environment'
|
|
4
4
|
require_relative '../push_execution_environment'
|
|
5
5
|
require_relative '../../helpers/execution_environment_helpers'
|
|
6
|
+
require_relative '../../runners/ansible_builder_runner'
|
|
7
|
+
require_relative '../../runners/ansible_navigator_runner'
|
|
6
8
|
require_relative '../../runners/meta_runner'
|
|
7
|
-
require 'smart_proxy_dynflow/callback'
|
|
8
9
|
|
|
9
10
|
module Proxy
|
|
10
11
|
module AnsibleDirector
|
|
11
12
|
module Actions
|
|
12
13
|
module Meta
|
|
13
14
|
class RunPlaybook < ::Proxy::Dynflow::Action::Runner
|
|
15
|
+
RUNNER_PHASES = [
|
|
16
|
+
{ id: :build_ee, title: 'Building Execution Environment',
|
|
17
|
+
runner_class: ::Proxy::AnsibleDirector::Runners::AnsibleBuilderRunner,
|
|
18
|
+
runner_input_key: :build_ee_input },
|
|
19
|
+
{ id: :run_ansible, title: 'Running Ansible',
|
|
20
|
+
runner_class: ::Proxy::AnsibleDirector::Runners::AnsibleNavigatorRunner,
|
|
21
|
+
runner_input_key: :run_ansible_input }
|
|
22
|
+
].freeze
|
|
23
|
+
|
|
14
24
|
def initiate_runner
|
|
15
25
|
execution_environment = input['execution_environment']
|
|
16
26
|
|
|
17
|
-
|
|
18
|
-
ee_registry_url = execution_environment['registry_url']
|
|
27
|
+
ee_pull_url = execution_environment['pull_url']
|
|
19
28
|
ee_ansible_core_version = execution_environment['ansible_core_version']
|
|
20
29
|
|
|
30
|
+
ee_run_image_tag = ee_pull_url.sub("latest",
|
|
31
|
+
@caller_execution_plan_id)
|
|
21
32
|
|
|
22
33
|
inventory = input['inventory']
|
|
23
34
|
playbook = input['playbook']
|
|
24
|
-
|
|
35
|
+
variable_files = input['variable_files'].to_hash
|
|
25
36
|
content = ::Proxy::AnsibleDirector::Helpers::ExecutionEnvironmentHelpers.format_content(
|
|
26
37
|
input['content']
|
|
27
38
|
)
|
|
28
39
|
|
|
29
40
|
::Proxy::AnsibleDirector::Runners::MetaRunner.new(
|
|
41
|
+
RUNNER_PHASES,
|
|
30
42
|
{
|
|
31
43
|
build_ee_input: {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
ee_built_image_tag: @caller_execution_plan_id,
|
|
44
|
+
ee_base_image_url: ee_pull_url,
|
|
45
|
+
ee_built_image_tag: ee_run_image_tag,
|
|
35
46
|
ee_ansible_core_version: ee_ansible_core_version,
|
|
36
47
|
ee_formatted_content: content,
|
|
37
48
|
is_base_image: false
|
|
@@ -39,9 +50,8 @@ module Proxy
|
|
|
39
50
|
run_ansible_input: {
|
|
40
51
|
inventory: inventory,
|
|
41
52
|
playbook: playbook,
|
|
42
|
-
|
|
43
|
-
execution_environment:
|
|
44
|
-
@caller_execution_plan_id)
|
|
53
|
+
variable_files: variable_files,
|
|
54
|
+
execution_environment: ee_run_image_tag
|
|
45
55
|
}
|
|
46
56
|
}
|
|
47
57
|
)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require_relative 'version'
|
|
4
|
+
require 'fileutils'
|
|
4
5
|
|
|
5
6
|
module Proxy
|
|
6
7
|
module AnsibleDirector
|
|
@@ -9,8 +10,9 @@ module Proxy
|
|
|
9
10
|
rackup_path File.expand_path('http_config.ru', __dir__)
|
|
10
11
|
|
|
11
12
|
default_settings(
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
workdir_root: "/usr/share/foreman-proxy/.ansible_director",
|
|
14
|
+
ansible_navigator_run_dir: "run",
|
|
15
|
+
execution_env_build_dir: "execution_env",
|
|
14
16
|
remove_workdirs: true
|
|
15
17
|
)
|
|
16
18
|
|
|
@@ -21,7 +23,43 @@ module Proxy
|
|
|
21
23
|
require 'smart_proxy_ansible_director/runners'
|
|
22
24
|
end
|
|
23
25
|
|
|
24
|
-
|
|
26
|
+
after_activation do
|
|
27
|
+
FileUtils.mkdir_p(
|
|
28
|
+
Proxy::AnsibleDirector::Plugin.settings[:workdir_root]
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
[
|
|
32
|
+
Proxy::AnsibleDirector::Plugin.settings[:ansible_navigator_run_dir],
|
|
33
|
+
Proxy::AnsibleDirector::Plugin.settings[:execution_env_build_dir],
|
|
34
|
+
"certs"
|
|
35
|
+
].each do |dir|
|
|
36
|
+
FileUtils.mkdir_p(
|
|
37
|
+
File.join(
|
|
38
|
+
Proxy::AnsibleDirector::Plugin.settings[:workdir_root],
|
|
39
|
+
dir
|
|
40
|
+
)
|
|
41
|
+
)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# This symlinks the foreman client certs to the new directory, as the certificates have to adhere to a specific
|
|
45
|
+
# naming scheme.
|
|
46
|
+
# See: https://man.archlinux.org/man/containers-certs.d.5.en#Directory_Structure
|
|
47
|
+
FileUtils.ln_sf(Proxy::SETTINGS.foreman_ssl_cert, File.join(
|
|
48
|
+
Proxy::AnsibleDirector::Plugin.settings[:workdir_root],
|
|
49
|
+
"certs",
|
|
50
|
+
"client.cert"
|
|
51
|
+
))
|
|
52
|
+
FileUtils.ln_sf(Proxy::SETTINGS.foreman_ssl_ca, File.join(
|
|
53
|
+
Proxy::AnsibleDirector::Plugin.settings[:workdir_root],
|
|
54
|
+
"certs",
|
|
55
|
+
"ca.crt"
|
|
56
|
+
))
|
|
57
|
+
FileUtils.ln_sf(Proxy::SETTINGS.foreman_ssl_key, File.join(
|
|
58
|
+
Proxy::AnsibleDirector::Plugin.settings[:workdir_root],
|
|
59
|
+
"certs",
|
|
60
|
+
"client.key"
|
|
61
|
+
))
|
|
62
|
+
|
|
25
63
|
Proxy::Dynflow::TaskLauncherRegistry.register('ansible-builder',
|
|
26
64
|
::Proxy::AnsibleDirector::Launchers::AnsibleBuilderLauncher)
|
|
27
65
|
Proxy::Dynflow::TaskLauncherRegistry.register('ansible-navigator',
|
|
@@ -18,8 +18,6 @@ module Proxy
|
|
|
18
18
|
# ee_formatted_content: ee_formatted_content
|
|
19
19
|
# }
|
|
20
20
|
def initialize(ansible_builder_input, suspended_action: nil)
|
|
21
|
-
# ID of the execution environment definition; supplied by Foreman
|
|
22
|
-
@ee_id = ansible_builder_input[:ee_id]
|
|
23
21
|
# TAGGED registry URL of the base image; supplied by Foreman
|
|
24
22
|
@ee_base_image_url = ansible_builder_input[:ee_base_image_url]
|
|
25
23
|
# Tag used at the end of building for this image
|
|
@@ -28,12 +26,19 @@ module Proxy
|
|
|
28
26
|
@ee_formatted_content = ansible_builder_input[:ee_formatted_content]
|
|
29
27
|
@is_base_image = ansible_builder_input[:is_base_image]
|
|
30
28
|
|
|
31
|
-
workdir_base =
|
|
29
|
+
workdir_base = File.join(
|
|
30
|
+
Proxy::AnsibleDirector::Plugin.settings[:workdir_root],
|
|
31
|
+
Proxy::AnsibleDirector::Plugin.settings[:execution_env_build_dir]
|
|
32
|
+
)
|
|
32
33
|
@runner_workdir = Dir.mktmpdir('execution_env', workdir_base)
|
|
33
34
|
super suspended_action: suspended_action
|
|
34
35
|
end
|
|
35
36
|
|
|
36
37
|
def start
|
|
38
|
+
cert_dir = File.join(
|
|
39
|
+
Proxy::AnsibleDirector::Plugin.settings[:workdir_root],
|
|
40
|
+
'certs'
|
|
41
|
+
)
|
|
37
42
|
ee_content = @ee_formatted_content.to_hash
|
|
38
43
|
ee_content.transform_values! do |value|
|
|
39
44
|
value.map do |cuv|
|
|
@@ -82,12 +87,7 @@ module Proxy
|
|
|
82
87
|
{
|
|
83
88
|
'prepend_base' => [
|
|
84
89
|
'ENV ANSIBLE_CALLBACK_WHITELIST=theforeman.foreman.foreman',
|
|
85
|
-
'ENV ANSIBLE_CALLBACKS_ENABLED=theforeman.foreman.foreman'
|
|
86
|
-
"ENV FOREMAN_URL=#{Proxy::SETTINGS.foreman_url}",
|
|
87
|
-
'ENV FOREMAN_SSL_CERT=/run/secrets/foreman_ssl_cert',
|
|
88
|
-
'ENV FOREMAN_SSL_KEY=/run/secrets/foreman_ssl_key',
|
|
89
|
-
'ENV FOREMAN_SSL_VERIFY=/run/secrets/foreman_ssl_verify'
|
|
90
|
-
|
|
90
|
+
'ENV ANSIBLE_CALLBACKS_ENABLED=theforeman.foreman.foreman'
|
|
91
91
|
]
|
|
92
92
|
}
|
|
93
93
|
end
|
|
@@ -107,14 +107,14 @@ module Proxy
|
|
|
107
107
|
# COMPAT 3.16 - 2
|
|
108
108
|
# --extra-build-cli-args is not supported in ansible-builder 3.0.0
|
|
109
109
|
# Verbosity is chosen by passing -v {0, 1, 2, 3}
|
|
110
|
-
|
|
111
110
|
cmd = <<~CMD
|
|
112
111
|
echo "Running in #{@runner_workdir}"
|
|
113
112
|
|
|
114
113
|
cat <<EOF > "#{@runner_workdir}/execution-environment.yml"
|
|
115
114
|
#{YAML.dump(ee_definition, indentation: 2)}
|
|
116
115
|
EOF
|
|
117
|
-
ansible-builder
|
|
116
|
+
ansible-builder create --verbosity 3 --file #{@runner_workdir}/execution-environment.yml --context #{@runner_workdir}
|
|
117
|
+
podman build --cert-dir #{cert_dir} --tag #{@ee_built_image_tag} --log-level=info --tag #{@ee_built_image_tag} #{build_args_str} #{@runner_workdir}
|
|
118
118
|
CMD
|
|
119
119
|
|
|
120
120
|
initialize_command('bash', '-c', cmd)
|
|
@@ -17,14 +17,17 @@ module Proxy
|
|
|
17
17
|
@inventory = ::Proxy::AnsibleDirector::Helpers::AnsibleNavigatorHelpers.reserialize_inventory(ansible_input[:inventory])
|
|
18
18
|
if ansible_input[:mode] == 'literal'
|
|
19
19
|
@playbook = ansible_input[:playbook]
|
|
20
|
-
@
|
|
20
|
+
@variable_files = {}
|
|
21
21
|
else
|
|
22
22
|
@playbook = ::Proxy::AnsibleDirector::Helpers::AnsibleNavigatorHelpers.reserialize_playbook(ansible_input[:playbook])
|
|
23
|
-
@
|
|
23
|
+
@variable_files = ansible_input[:variable_files]
|
|
24
24
|
end
|
|
25
25
|
@execution_environment = ansible_input[:execution_environment]
|
|
26
26
|
|
|
27
|
-
workdir_base =
|
|
27
|
+
workdir_base = File.join(
|
|
28
|
+
Proxy::AnsibleDirector::Plugin.settings[:workdir_root],
|
|
29
|
+
Proxy::AnsibleDirector::Plugin.settings[:ansible_navigator_run_dir]
|
|
30
|
+
)
|
|
28
31
|
@runner_workdir = Dir.mktmpdir('navigator', workdir_base)
|
|
29
32
|
end
|
|
30
33
|
|
|
@@ -32,6 +35,12 @@ module Proxy
|
|
|
32
35
|
# TODO: Find a way to request the auth token programmatically
|
|
33
36
|
proxy_ssh_key_path = ::Proxy::RemoteExecution::Ssh::Plugin.settings[:ssh_identity_key_file]
|
|
34
37
|
proxy_ssh_key_mount_path = "/runner/.ssh/#{File.basename(proxy_ssh_key_path)}"
|
|
38
|
+
|
|
39
|
+
foreman_certs_path = '/secrets/foreman/certs'
|
|
40
|
+
foreman_ssl_cert_mount_path = "#{foreman_certs_path}/#{File.basename(Proxy::SETTINGS.foreman_ssl_cert)}"
|
|
41
|
+
foreman_ssl_key_mount_path = "#{foreman_certs_path}/#{File.basename(Proxy::SETTINGS.foreman_ssl_key)}"
|
|
42
|
+
foreman_ssl_ca_mount_path = "#{foreman_certs_path}/#{File.basename(Proxy::SETTINGS.foreman_ssl_ca)}"
|
|
43
|
+
|
|
35
44
|
cmd = <<~CMD
|
|
36
45
|
echo "Running in #{@runner_workdir}"
|
|
37
46
|
|
|
@@ -46,8 +55,8 @@ module Proxy
|
|
|
46
55
|
mkdir #{@runner_workdir}/vars
|
|
47
56
|
|
|
48
57
|
#{
|
|
49
|
-
@
|
|
50
|
-
%(cat > "#{@runner_workdir}/vars/#{
|
|
58
|
+
@variable_files.map do |file_name, file_content64|
|
|
59
|
+
%(cat > "#{@runner_workdir}/vars/#{file_name}" <<'EOF'\n#{Base64.decode64(file_content64)}EOF)
|
|
51
60
|
end.join("\n\n")
|
|
52
61
|
}
|
|
53
62
|
|
|
@@ -70,14 +79,20 @@ module Proxy
|
|
|
70
79
|
- "--authfile=$AUTHFILE"
|
|
71
80
|
policy: missing
|
|
72
81
|
volume-mounts:
|
|
73
|
-
- src: #{
|
|
74
|
-
dest:
|
|
75
|
-
- src: #{
|
|
76
|
-
dest:
|
|
77
|
-
- src: #{
|
|
78
|
-
dest:
|
|
82
|
+
- src: #{Proxy::SETTINGS.foreman_ssl_cert}
|
|
83
|
+
dest: #{foreman_ssl_cert_mount_path}
|
|
84
|
+
- src: #{Proxy::SETTINGS.foreman_ssl_key}
|
|
85
|
+
dest: #{foreman_ssl_key_mount_path}
|
|
86
|
+
- src: #{Proxy::SETTINGS.foreman_ssl_ca}
|
|
87
|
+
dest: #{foreman_ssl_ca_mount_path}
|
|
79
88
|
- src: #{proxy_ssh_key_path}
|
|
80
89
|
dest: #{proxy_ssh_key_mount_path}
|
|
90
|
+
environment-variables:
|
|
91
|
+
set:
|
|
92
|
+
FOREMAN_URL: #{Proxy::SETTINGS.foreman_url}
|
|
93
|
+
FOREMAN_SSL_CERT: #{foreman_ssl_cert_mount_path}
|
|
94
|
+
FOREMAN_SSL_KEY: #{foreman_ssl_key_mount_path}
|
|
95
|
+
FOREMAN_SSL_VERIFY: #{foreman_ssl_ca_mount_path}
|
|
81
96
|
logging:
|
|
82
97
|
level: debug
|
|
83
98
|
file: #{@runner_workdir}/ansible-navigator.log
|
|
@@ -104,22 +119,6 @@ module Proxy
|
|
|
104
119
|
remove_workdirs = Proxy::AnsibleDirector::Plugin.settings[:remove_workdirs]
|
|
105
120
|
FileUtils.rm_rf @runner_workdir if remove_workdirs
|
|
106
121
|
end
|
|
107
|
-
|
|
108
|
-
private
|
|
109
|
-
|
|
110
|
-
def format_variables(_role_name, variables)
|
|
111
|
-
formatted = {}
|
|
112
|
-
variables.each do |k, v|
|
|
113
|
-
formatted_v = begin
|
|
114
|
-
YAML.safe_load v
|
|
115
|
-
rescue Exception
|
|
116
|
-
v
|
|
117
|
-
end
|
|
118
|
-
formatted[k] = formatted_v
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
formatted.to_h.to_yaml
|
|
122
|
-
end
|
|
123
122
|
end
|
|
124
123
|
end
|
|
125
124
|
end
|
|
@@ -6,15 +6,12 @@ module Proxy
|
|
|
6
6
|
module AnsibleDirector
|
|
7
7
|
module Runners
|
|
8
8
|
class MetaRunner < ::Proxy::Dynflow::Runner::Base
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
runner_input_key: :run_ansible_input }
|
|
14
|
-
].freeze
|
|
15
|
-
|
|
16
|
-
def initialize(input, suspended_action: nil)
|
|
9
|
+
CYAN = "\e[36m"
|
|
10
|
+
RESET = "\e[0m"
|
|
11
|
+
|
|
12
|
+
def initialize(phases, input, suspended_action: nil)
|
|
17
13
|
super(suspended_action: suspended_action)
|
|
14
|
+
@phases = phases
|
|
18
15
|
@input = input
|
|
19
16
|
@phase_index = 0
|
|
20
17
|
@current_runner = nil
|
|
@@ -52,14 +49,14 @@ module Proxy
|
|
|
52
49
|
private
|
|
53
50
|
|
|
54
51
|
def transition_to_phase(index)
|
|
55
|
-
phase_info =
|
|
52
|
+
phase_info = @phases[index]
|
|
56
53
|
|
|
57
54
|
@phase_index = index
|
|
58
55
|
runner_class = phase_info[:runner_class]
|
|
59
56
|
runner_input = @input[phase_info[:runner_input_key]]
|
|
60
57
|
|
|
61
58
|
@continuous_output.add_output(
|
|
62
|
-
"START: Phase #{phase_info[:id]} (#{index + 1} / #{
|
|
59
|
+
"#{CYAN}START: Phase #{phase_info[:id]} (#{index + 1} / #{@phases.length}): #{phase_info[:title]}#{RESET}\n"
|
|
63
60
|
)
|
|
64
61
|
|
|
65
62
|
@current_runner = runner_class.new(runner_input, suspended_action: @suspended_action)
|
|
@@ -67,12 +64,12 @@ module Proxy
|
|
|
67
64
|
end
|
|
68
65
|
|
|
69
66
|
def transition_to_next_phase
|
|
70
|
-
phase_info =
|
|
67
|
+
phase_info = @phases[@phase_index]
|
|
71
68
|
@continuous_output.add_output(
|
|
72
|
-
"END: Phase #{phase_info[:id]}: #{phase_info[:title]}\n"
|
|
69
|
+
"#{CYAN}END: Phase #{phase_info[:id]}: #{phase_info[:title]}#{RESET}\n"
|
|
73
70
|
)
|
|
74
71
|
|
|
75
|
-
if @phase_index + 1 <
|
|
72
|
+
if @phase_index + 1 < @phases.length
|
|
76
73
|
@phase_index += 1
|
|
77
74
|
transition_to_phase(@phase_index)
|
|
78
75
|
else
|
|
@@ -15,8 +15,12 @@ module Proxy
|
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
def start
|
|
18
|
+
cert_dir = File.join(
|
|
19
|
+
Proxy::AnsibleDirector::Plugin.settings[:workdir_root],
|
|
20
|
+
'certs'
|
|
21
|
+
)
|
|
18
22
|
cmd = <<~CMD
|
|
19
|
-
podman pull --
|
|
23
|
+
podman pull --cert-dir #{cert_dir} #{@ee_registry_url}
|
|
20
24
|
CMD
|
|
21
25
|
initialize_command('bash', '-c', cmd)
|
|
22
26
|
end
|
|
@@ -9,20 +9,20 @@ module Proxy
|
|
|
9
9
|
class PodmanPushRunner < ::Proxy::Dynflow::Runner::Base
|
|
10
10
|
include ::Proxy::Dynflow::Runner::ProcessManagerCommand
|
|
11
11
|
|
|
12
|
+
attr_reader :continuous_output, :exit_status
|
|
13
|
+
|
|
12
14
|
def initialize(podman_push_input, suspended_action: nil)
|
|
13
15
|
super suspended_action: suspended_action
|
|
14
|
-
|
|
15
|
-
@ee_id = podman_push_input[:ee_id]
|
|
16
|
+
@push_url = podman_push_input[:push_url]
|
|
16
17
|
end
|
|
17
18
|
|
|
18
19
|
def start
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
cert_dir = File.join(
|
|
21
|
+
Proxy::AnsibleDirector::Plugin.settings[:workdir_root],
|
|
22
|
+
'certs'
|
|
23
|
+
)
|
|
24
24
|
cmd = <<~CMD
|
|
25
|
-
podman push --
|
|
25
|
+
podman push --cert-dir #{cert_dir} #{@push_url}
|
|
26
26
|
CMD
|
|
27
27
|
initialize_command('bash', '-c', cmd)
|
|
28
28
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: smart_proxy_ansible_director
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.7.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- ATIX AG
|
|
@@ -149,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
149
149
|
- !ruby/object:Gem::Version
|
|
150
150
|
version: '0'
|
|
151
151
|
requirements: []
|
|
152
|
-
rubygems_version: 4.0.
|
|
152
|
+
rubygems_version: 4.0.20
|
|
153
153
|
specification_version: 4
|
|
154
154
|
summary: Smart Proxy plugin to integrate Ansible Director with Foreman
|
|
155
155
|
test_files: []
|