smart_proxy_ansible_director 0.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 11b4f80f48a4372c163be6a36eaac462054a9b8faeeecdf19bd8c1de4b3aae05
4
- data.tar.gz: 0cc24d6656aacfebc1bc1be8a8b39e741faaf467f90b0a5055ba5a6589d6b8bb
3
+ metadata.gz: ecd7bca9499c92013e47ab4de68b7172c2f1d0d37a89d4b6f5de7b5319bc0405
4
+ data.tar.gz: d389d6b6cad1752b5f80efe3cfd6ee6ac2c2a61a7f03231a0b86a44d015ae77d
5
5
  SHA512:
6
- metadata.gz: 710655ed3b2ee6b8b7c553da0ff6a3e358e99e2b103bd1655b992af6ebfc4b8d3a27e8aa0230c454ed77f3a73896a3f335d3645e680505d6e5bc14a848e1d87e
7
- data.tar.gz: a37793192570e852c6587350dc6216b03bfe50934122e67a2fc8e871b6546f9134729e0d7097a9104ea538a4662b9c08fb50dec1c6a41c4cbb7b534284064653
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
- # "action_input": {
13
- # "execution_environment": {
14
- # "id": 1,
15
- # "content": {
16
- # "base_image": "registry.fedoraproject.org/fedora:42",
17
- # "ansible_core_version": "",
18
- # "content_units": [
19
- # {
20
- # "type": "collection",
21
- # "identifier": "nextcloud.admin",
22
- # "version": "2.0.0",
23
- # "source": "https://galaxy.ansible.com"
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 = 'latest'
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
- sequence do
43
- plan_action ::Proxy::AnsibleDirector::Actions::BuildExecutionEnvironment, {
44
- ee_id: ee_id,
45
- ee_base_image_url: ee_base_image,
46
- ee_built_image_tag: ee_base_image_tag,
47
- ee_ansible_core_version: ee_ansible_core_version,
48
- ee_formatted_content: ee_formatted_content,
49
- is_base_image: true
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
- # COMPAT 3.16 - 3
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: "#{execution_environment.split('/')[-1]}:latest"
24
+ execution_environment: execution_environment
25
25
  }
26
26
  plan_action ::Proxy::Dynflow::Callback::Action,
27
27
  args[:callback],
@@ -3,47 +3,58 @@
3
3
  require_relative '../build_execution_environment'
4
4
  require_relative '../push_execution_environment'
5
5
  require_relative '../../helpers/execution_environment_helpers'
6
- require 'smart_proxy_dynflow/callback'
6
+ require_relative '../../runners/ansible_builder_runner'
7
+ require_relative '../../runners/ansible_navigator_runner'
8
+ require_relative '../../runners/meta_runner'
7
9
 
8
10
  module Proxy
9
11
  module AnsibleDirector
10
12
  module Actions
11
13
  module Meta
12
14
  class RunPlaybook < ::Proxy::Dynflow::Action::Runner
13
- def plan(args)
14
- execution_environment = 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: :run_ansible, title: 'Running Ansible',
20
+ runner_class: ::Proxy::AnsibleDirector::Runners::AnsibleNavigatorRunner,
21
+ runner_input_key: :run_ansible_input }
22
+ ].freeze
15
23
 
16
- ee_id = execution_environment['id']
17
- ee_registry_url = execution_environment['registry_url']
24
+ def initiate_runner
25
+ execution_environment = input['execution_environment']
26
+
27
+ ee_pull_url = execution_environment['pull_url']
18
28
  ee_ansible_core_version = execution_environment['ansible_core_version']
19
29
 
30
+ ee_run_image_tag = ee_pull_url.sub("latest",
31
+ @caller_execution_plan_id)
20
32
 
21
- inventory = args['inventory']
22
- playbook = args['playbook']
23
- variables = args['variables']
33
+ inventory = input['inventory']
34
+ playbook = input['playbook']
35
+ variable_files = input['variable_files'].to_hash
24
36
  content = ::Proxy::AnsibleDirector::Helpers::ExecutionEnvironmentHelpers.format_content(
25
- args['content']
37
+ input['content']
26
38
  )
27
39
 
28
- sequence do
29
- plan_action ::Proxy::AnsibleDirector::Actions::BuildExecutionEnvironment, {
30
- ee_id: ee_id,
31
- ee_base_image_url: ee_registry_url,
32
- ee_built_image_tag: @caller_execution_plan_id,
33
- ee_ansible_core_version: ee_ansible_core_version,
34
- ee_formatted_content: content,
35
- is_base_image: false
36
- }
37
- run_ansible_action = plan_action ::Proxy::AnsibleDirector::Actions::RunAnsibleNavigator, {
38
- inventory: inventory,
39
- playbook: playbook,
40
- variables: variables,
41
- execution_environment: ee_registry_url.sub!("latest", @caller_execution_plan_id)
40
+ ::Proxy::AnsibleDirector::Runners::MetaRunner.new(
41
+ RUNNER_PHASES,
42
+ {
43
+ build_ee_input: {
44
+ ee_base_image_url: ee_pull_url,
45
+ ee_built_image_tag: ee_run_image_tag,
46
+ ee_ansible_core_version: ee_ansible_core_version,
47
+ ee_formatted_content: content,
48
+ is_base_image: false
49
+ },
50
+ run_ansible_input: {
51
+ inventory: inventory,
52
+ playbook: playbook,
53
+ variable_files: variable_files,
54
+ execution_environment: ee_run_image_tag
55
+ }
42
56
  }
43
- plan_action ::Proxy::Dynflow::Callback::Action,
44
- args[:callback],
45
- run_ansible_action.output
46
- end
57
+ )
47
58
  end
48
59
  end
49
60
  end
@@ -11,9 +11,9 @@ module Proxy
11
11
 
12
12
  content_units.each do |content_unit|
13
13
  formatted_unit = {
14
- name: content_unit['identifier'],
15
- version: content_unit['version'],
16
- source: content_unit['source']
14
+ 'name' => content_unit['identifier'],
15
+ 'version' => content_unit['version'],
16
+ 'source' => content_unit['source']
17
17
  }
18
18
 
19
19
  case content_unit['type']
@@ -24,8 +24,8 @@ module Proxy
24
24
  end
25
25
  end
26
26
  {
27
- collections: collections.length.positive? ? collections : nil,
28
- roles: roles.length.positive? ? roles : nil
27
+ 'collections' => collections.length.positive? ? collections : nil,
28
+ 'roles' => roles.length.positive? ? roles : nil
29
29
  }.compact!
30
30
  end
31
31
 
@@ -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
- ansible_navigator_run_dir: "/usr/share/foreman-proxy/.ansible_director/run",
13
- execution_env_build_dir: "/usr/share/foreman-proxy/.ansible_director/execution_env",
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
- load_dependency_injection_wirings do |_container_instance, _settings|
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',
@@ -8,6 +8,8 @@ module Proxy
8
8
  class AnsibleBuilderRunner < ::Proxy::Dynflow::Runner::Base
9
9
  include ::Proxy::Dynflow::Runner::ProcessManagerCommand
10
10
 
11
+ attr_reader :continuous_output, :exit_status
12
+
11
13
  # ansible_builder_input
12
14
  # {
13
15
  # ee_id: ee_id,
@@ -16,8 +18,6 @@ module Proxy
16
18
  # ee_formatted_content: ee_formatted_content
17
19
  # }
18
20
  def initialize(ansible_builder_input, suspended_action: nil)
19
- # ID of the execution environment definition; supplied by Foreman
20
- @ee_id = ansible_builder_input[:ee_id]
21
21
  # TAGGED registry URL of the base image; supplied by Foreman
22
22
  @ee_base_image_url = ansible_builder_input[:ee_base_image_url]
23
23
  # Tag used at the end of building for this image
@@ -26,13 +26,29 @@ module Proxy
26
26
  @ee_formatted_content = ansible_builder_input[:ee_formatted_content]
27
27
  @is_base_image = ansible_builder_input[:is_base_image]
28
28
 
29
- workdir_base = Proxy::AnsibleDirector::Plugin.settings[:execution_env_build_dir]
29
+ workdir_base = File.join(
30
+ Proxy::AnsibleDirector::Plugin.settings[:workdir_root],
31
+ Proxy::AnsibleDirector::Plugin.settings[:execution_env_build_dir]
32
+ )
30
33
  @runner_workdir = Dir.mktmpdir('execution_env', workdir_base)
31
34
  super suspended_action: suspended_action
32
35
  end
33
36
 
34
37
  def start
38
+ cert_dir = File.join(
39
+ Proxy::AnsibleDirector::Plugin.settings[:workdir_root],
40
+ 'certs'
41
+ )
35
42
  ee_content = @ee_formatted_content.to_hash
43
+ ee_content.transform_values! do |value|
44
+ value.map do |cuv|
45
+ {
46
+ 'name' => cuv['name'],
47
+ 'source' => cuv['source'],
48
+ 'version' => cuv['version']
49
+ }.compact
50
+ end
51
+ end
36
52
 
37
53
  if @is_base_image
38
54
  ee_content.merge!(
@@ -71,12 +87,7 @@ module Proxy
71
87
  {
72
88
  'prepend_base' => [
73
89
  'ENV ANSIBLE_CALLBACK_WHITELIST=theforeman.foreman.foreman',
74
- 'ENV ANSIBLE_CALLBACKS_ENABLED=theforeman.foreman.foreman',
75
- "ENV FOREMAN_URL=#{Proxy::SETTINGS.foreman_url}",
76
- 'ENV FOREMAN_SSL_CERT=/run/secrets/foreman_ssl_cert',
77
- 'ENV FOREMAN_SSL_KEY=/run/secrets/foreman_ssl_key',
78
- 'ENV FOREMAN_SSL_VERIFY=/run/secrets/foreman_ssl_verify'
79
-
90
+ 'ENV ANSIBLE_CALLBACKS_ENABLED=theforeman.foreman.foreman'
80
91
  ]
81
92
  }
82
93
  end
@@ -96,14 +107,14 @@ module Proxy
96
107
  # COMPAT 3.16 - 2
97
108
  # --extra-build-cli-args is not supported in ansible-builder 3.0.0
98
109
  # Verbosity is chosen by passing -v {0, 1, 2, 3}
99
-
100
110
  cmd = <<~CMD
101
111
  echo "Running in #{@runner_workdir}"
102
112
 
103
113
  cat <<EOF > "#{@runner_workdir}/execution-environment.yml"
104
114
  #{YAML.dump(ee_definition, indentation: 2)}
105
115
  EOF
106
- ansible-builder build --tag ansible_director/#{@ee_id}:#{@ee_built_image_tag} -v 3 --file #{@runner_workdir}/execution-environment.yml #{build_args_str} --context #{@runner_workdir}
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}
107
118
  CMD
108
119
 
109
120
  initialize_command('bash', '-c', cmd)
@@ -10,24 +10,37 @@ module Proxy
10
10
  class AnsibleNavigatorRunner < ::Proxy::Dynflow::Runner::Base
11
11
  include ::Proxy::Dynflow::Runner::ProcessManagerCommand
12
12
 
13
+ attr_reader :continuous_output, :exit_status
14
+
13
15
  def initialize(ansible_input, suspended_action: nil)
14
16
  super suspended_action: suspended_action
15
17
  @inventory = ::Proxy::AnsibleDirector::Helpers::AnsibleNavigatorHelpers.reserialize_inventory(ansible_input[:inventory])
16
18
  if ansible_input[:mode] == 'literal'
17
19
  @playbook = ansible_input[:playbook]
18
- @variables = {}
20
+ @variable_files = {}
19
21
  else
20
22
  @playbook = ::Proxy::AnsibleDirector::Helpers::AnsibleNavigatorHelpers.reserialize_playbook(ansible_input[:playbook])
21
- @variables = ansible_input[:variables]
23
+ @variable_files = ansible_input[:variable_files]
22
24
  end
23
25
  @execution_environment = ansible_input[:execution_environment]
24
26
 
25
- workdir_base = Proxy::AnsibleDirector::Plugin.settings[:ansible_navigator_run_dir]
27
+ workdir_base = File.join(
28
+ Proxy::AnsibleDirector::Plugin.settings[:workdir_root],
29
+ Proxy::AnsibleDirector::Plugin.settings[:ansible_navigator_run_dir]
30
+ )
26
31
  @runner_workdir = Dir.mktmpdir('navigator', workdir_base)
27
32
  end
28
33
 
29
34
  def start
30
35
  # TODO: Find a way to request the auth token programmatically
36
+ proxy_ssh_key_path = ::Proxy::RemoteExecution::Ssh::Plugin.settings[:ssh_identity_key_file]
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
+
31
44
  cmd = <<~CMD
32
45
  echo "Running in #{@runner_workdir}"
33
46
 
@@ -42,8 +55,8 @@ module Proxy
42
55
  mkdir #{@runner_workdir}/vars
43
56
 
44
57
  #{
45
- @variables.map do |role_name, variables|
46
- %(cat > "#{@runner_workdir}/vars/#{role_name}_vars.yaml" <<'EOF'\n#{format_variables role_name, variables}EOF)
58
+ @variable_files.map do |file_name, file_content64|
59
+ %(cat > "#{@runner_workdir}/vars/#{file_name}" <<'EOF'\n#{Base64.decode64(file_content64)}EOF)
47
60
  end.join("\n\n")
48
61
  }
49
62
 
@@ -66,14 +79,20 @@ module Proxy
66
79
  - "--authfile=$AUTHFILE"
67
80
  policy: missing
68
81
  volume-mounts:
69
- - src: #{File.join(Dir.pwd, Proxy::SETTINGS.foreman_ssl_cert)}
70
- dest: /run/secrets/foreman_ssl_cert
71
- - src: #{File.join(Dir.pwd, Proxy::SETTINGS.foreman_ssl_key)}
72
- dest: /run/secrets/foreman_ssl_key
73
- - src: #{File.join(Dir.pwd, Proxy::SETTINGS.foreman_ssl_ca)}
74
- dest: /run/secrets/foreman_ssl_verify
75
- - src: /usr/share/foreman-proxy/.ssh/id_rsa_foreman_proxy
76
- dest: /runner/.ssh/id_rsa_foreman_proxy
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}
88
+ - src: #{proxy_ssh_key_path}
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}
77
96
  logging:
78
97
  level: debug
79
98
  file: #{@runner_workdir}/ansible-navigator.log
@@ -81,7 +100,7 @@ module Proxy
81
100
  EOF
82
101
 
83
102
  cd #{@runner_workdir}/
84
- ansible-navigator run --mode stdout
103
+ ansible-navigator run --private-key=#{proxy_ssh_key_mount_path}
85
104
  CMD
86
105
  initialize_command('bash', '-c', cmd)
87
106
  end
@@ -100,22 +119,6 @@ module Proxy
100
119
  remove_workdirs = Proxy::AnsibleDirector::Plugin.settings[:remove_workdirs]
101
120
  FileUtils.rm_rf @runner_workdir if remove_workdirs
102
121
  end
103
-
104
- private
105
-
106
- def format_variables(_role_name, variables)
107
- formatted = {}
108
- variables.each do |k, v|
109
- formatted_v = begin
110
- YAML.safe_load v
111
- rescue Exception
112
- v
113
- end
114
- formatted[k] = formatted_v
115
- end
116
-
117
- formatted.to_h.to_yaml
118
- end
119
122
  end
120
123
  end
121
124
  end
@@ -0,0 +1,82 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../runners'
4
+
5
+ module Proxy
6
+ module AnsibleDirector
7
+ module Runners
8
+ class MetaRunner < ::Proxy::Dynflow::Runner::Base
9
+ CYAN = "\e[36m"
10
+ RESET = "\e[0m"
11
+
12
+ def initialize(phases, input, suspended_action: nil)
13
+ super(suspended_action: suspended_action)
14
+ @phases = phases
15
+ @input = input
16
+ @phase_index = 0
17
+ @current_runner = nil
18
+ end
19
+
20
+ def start
21
+ transition_to_phase(@phase_index)
22
+ end
23
+
24
+ def refresh
25
+ return unless @current_runner
26
+
27
+ @current_runner.refresh
28
+
29
+ @continuous_output.raw_outputs.concat(@current_runner.continuous_output.raw_outputs)
30
+ @current_runner.continuous_output.raw_outputs.clear
31
+
32
+ return unless @current_runner.exit_status
33
+
34
+ if @current_runner.exit_status != 0
35
+ publish_exit_status(@current_runner.exit_status)
36
+ else
37
+ transition_to_next_phase
38
+ end
39
+ end
40
+
41
+ def kill
42
+ @current_runner&.kill
43
+ end
44
+
45
+ def close
46
+ @current_runner&.close
47
+ end
48
+
49
+ private
50
+
51
+ def transition_to_phase(index)
52
+ phase_info = @phases[index]
53
+
54
+ @phase_index = index
55
+ runner_class = phase_info[:runner_class]
56
+ runner_input = @input[phase_info[:runner_input_key]]
57
+
58
+ @continuous_output.add_output(
59
+ "#{CYAN}START: Phase #{phase_info[:id]} (#{index + 1} / #{@phases.length}): #{phase_info[:title]}#{RESET}\n"
60
+ )
61
+
62
+ @current_runner = runner_class.new(runner_input, suspended_action: @suspended_action)
63
+ @current_runner.start
64
+ end
65
+
66
+ def transition_to_next_phase
67
+ phase_info = @phases[@phase_index]
68
+ @continuous_output.add_output(
69
+ "#{CYAN}END: Phase #{phase_info[:id]}: #{phase_info[:title]}#{RESET}\n"
70
+ )
71
+
72
+ if @phase_index + 1 < @phases.length
73
+ @phase_index += 1
74
+ transition_to_phase(@phase_index)
75
+ else
76
+ publish_exit_status(0)
77
+ end
78
+ end
79
+ end
80
+ end
81
+ end
82
+ end
@@ -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 --tls-verify=false #{@ee_registry_url}
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
- puts podman_push_input
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
- # TODO: Parametrize
20
-
21
- image_name = "ansible_director/#{@ee_id}:latest"
22
- registry = 'centos9-katello-devel-stable.example.com:4321'
23
-
20
+ cert_dir = File.join(
21
+ Proxy::AnsibleDirector::Plugin.settings[:workdir_root],
22
+ 'certs'
23
+ )
24
24
  cmd = <<~CMD
25
- podman push --tls-verify=false #{image_name} #{registry}/#{image_name}
25
+ podman push --cert-dir #{cert_dir} #{@push_url}
26
26
  CMD
27
27
  initialize_command('bash', '-c', cmd)
28
28
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Proxy
4
4
  module AnsibleDirector
5
- VERSION = '0.5.0'
5
+ VERSION = '0.7.0'
6
6
  end
7
7
  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.5.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ATIX AG
@@ -29,6 +29,26 @@ dependencies:
29
29
  - - "<"
30
30
  - !ruby/object:Gem::Version
31
31
  version: 2.0.0
32
+ - !ruby/object:Gem::Dependency
33
+ name: smart_proxy_remote_execution_ssh
34
+ requirement: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: 0.11.6
39
+ - - "<"
40
+ - !ruby/object:Gem::Version
41
+ version: 2.0.0
42
+ type: :runtime
43
+ prerelease: false
44
+ version_requirements: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: 0.11.6
49
+ - - "<"
50
+ - !ruby/object:Gem::Version
51
+ version: 2.0.0
32
52
  - !ruby/object:Gem::Dependency
33
53
  name: mocha
34
54
  requirement: !ruby/object:Gem::Requirement
@@ -103,6 +123,7 @@ files:
103
123
  - lib/smart_proxy_ansible_director/runners.rb
104
124
  - lib/smart_proxy_ansible_director/runners/ansible_builder_runner.rb
105
125
  - lib/smart_proxy_ansible_director/runners/ansible_navigator_runner.rb
126
+ - lib/smart_proxy_ansible_director/runners/meta_runner.rb
106
127
  - lib/smart_proxy_ansible_director/runners/podman_pull_runner.rb
107
128
  - lib/smart_proxy_ansible_director/runners/podman_push_runner.rb
108
129
  - lib/smart_proxy_ansible_director/version.rb
@@ -128,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
128
149
  - !ruby/object:Gem::Version
129
150
  version: '0'
130
151
  requirements: []
131
- rubygems_version: 4.0.6
152
+ rubygems_version: 4.0.20
132
153
  specification_version: 4
133
154
  summary: Smart Proxy plugin to integrate Ansible Director with Foreman
134
155
  test_files: []