smart_proxy_ansible_director 0.4.0 → 0.6.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/run_playbook.rb +25 -24
- data/lib/smart_proxy_ansible_director/helpers/execution_environment_helpers.rb +5 -5
- data/lib/smart_proxy_ansible_director/runners/ansible_builder_runner.rb +11 -0
- data/lib/smart_proxy_ansible_director/runners/ansible_navigator_runner.rb +9 -4
- data/lib/smart_proxy_ansible_director/runners/meta_runner.rb +85 -0
- data/lib/smart_proxy_ansible_director/version.rb +1 -1
- metadata +33 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8b4c354edd008b22c1a7c3bb81961c43c0159083c8605b06c04f7a1d85bd5c32
|
|
4
|
+
data.tar.gz: edf3d06edeef438c682173531b0ac2e29911803afc448c2bcca3f1f5b1517090
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7522c49d2d8ff5aac7499681d8321d1fdbe6f879df564da7a1cf5a53d04a20dd8ceddb1a7817e4ff65fe5e704039c75f16072e1cf460bd7d30a2af28f370cbb4
|
|
7
|
+
data.tar.gz: e41d6d20ccf4729d5550b6909b7bf5f4151171f2999684712a87db978dd7c27a1f2f5621efbe14659a7d02647599a2e52a41c8c4798982ef98d25fcd283fcdd3
|
|
@@ -3,6 +3,7 @@
|
|
|
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/meta_runner'
|
|
6
7
|
require 'smart_proxy_dynflow/callback'
|
|
7
8
|
|
|
8
9
|
module Proxy
|
|
@@ -10,40 +11,40 @@ module Proxy
|
|
|
10
11
|
module Actions
|
|
11
12
|
module Meta
|
|
12
13
|
class RunPlaybook < ::Proxy::Dynflow::Action::Runner
|
|
13
|
-
def
|
|
14
|
-
execution_environment =
|
|
14
|
+
def initiate_runner
|
|
15
|
+
execution_environment = input['execution_environment']
|
|
15
16
|
|
|
16
17
|
ee_id = execution_environment['id']
|
|
17
18
|
ee_registry_url = execution_environment['registry_url']
|
|
18
19
|
ee_ansible_core_version = execution_environment['ansible_core_version']
|
|
19
20
|
|
|
20
21
|
|
|
21
|
-
inventory =
|
|
22
|
-
playbook =
|
|
23
|
-
variables =
|
|
22
|
+
inventory = input['inventory']
|
|
23
|
+
playbook = input['playbook']
|
|
24
|
+
variables = input['variables'].to_hash
|
|
24
25
|
content = ::Proxy::AnsibleDirector::Helpers::ExecutionEnvironmentHelpers.format_content(
|
|
25
|
-
|
|
26
|
+
input['content']
|
|
26
27
|
)
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
29
|
+
::Proxy::AnsibleDirector::Runners::MetaRunner.new(
|
|
30
|
+
{
|
|
31
|
+
build_ee_input: {
|
|
32
|
+
ee_id: ee_id,
|
|
33
|
+
ee_base_image_url: ee_registry_url,
|
|
34
|
+
ee_built_image_tag: @caller_execution_plan_id,
|
|
35
|
+
ee_ansible_core_version: ee_ansible_core_version,
|
|
36
|
+
ee_formatted_content: content,
|
|
37
|
+
is_base_image: false
|
|
38
|
+
},
|
|
39
|
+
run_ansible_input: {
|
|
40
|
+
inventory: inventory,
|
|
41
|
+
playbook: playbook,
|
|
42
|
+
variables: variables,
|
|
43
|
+
execution_environment: ee_registry_url.sub("latest",
|
|
44
|
+
@caller_execution_plan_id)
|
|
45
|
+
}
|
|
36
46
|
}
|
|
37
|
-
|
|
38
|
-
inventory: inventory,
|
|
39
|
-
playbook: playbook,
|
|
40
|
-
variables: variables,
|
|
41
|
-
execution_environment: ee_registry_url.sub!("latest", @caller_execution_plan_id)
|
|
42
|
-
}
|
|
43
|
-
plan_action ::Proxy::Dynflow::Callback::Action,
|
|
44
|
-
args[:callback],
|
|
45
|
-
run_ansible_action.output
|
|
46
|
-
end
|
|
47
|
+
)
|
|
47
48
|
end
|
|
48
49
|
end
|
|
49
50
|
end
|
|
@@ -11,9 +11,9 @@ module Proxy
|
|
|
11
11
|
|
|
12
12
|
content_units.each do |content_unit|
|
|
13
13
|
formatted_unit = {
|
|
14
|
-
name
|
|
15
|
-
version
|
|
16
|
-
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
|
|
28
|
-
roles
|
|
27
|
+
'collections' => collections.length.positive? ? collections : nil,
|
|
28
|
+
'roles' => roles.length.positive? ? roles : nil
|
|
29
29
|
}.compact!
|
|
30
30
|
end
|
|
31
31
|
|
|
@@ -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,
|
|
@@ -33,6 +35,15 @@ module Proxy
|
|
|
33
35
|
|
|
34
36
|
def start
|
|
35
37
|
ee_content = @ee_formatted_content.to_hash
|
|
38
|
+
ee_content.transform_values! do |value|
|
|
39
|
+
value.map do |cuv|
|
|
40
|
+
{
|
|
41
|
+
'name' => cuv['name'],
|
|
42
|
+
'source' => cuv['source'],
|
|
43
|
+
'version' => cuv['version']
|
|
44
|
+
}.compact
|
|
45
|
+
end
|
|
46
|
+
end
|
|
36
47
|
|
|
37
48
|
if @is_base_image
|
|
38
49
|
ee_content.merge!(
|
|
@@ -10,6 +10,8 @@ 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])
|
|
@@ -28,6 +30,8 @@ module Proxy
|
|
|
28
30
|
|
|
29
31
|
def start
|
|
30
32
|
# TODO: Find a way to request the auth token programmatically
|
|
33
|
+
proxy_ssh_key_path = ::Proxy::RemoteExecution::Ssh::Plugin.settings[:ssh_identity_key_file]
|
|
34
|
+
proxy_ssh_key_mount_path = "/runner/.ssh/#{File.basename(proxy_ssh_key_path)}"
|
|
31
35
|
cmd = <<~CMD
|
|
32
36
|
echo "Running in #{@runner_workdir}"
|
|
33
37
|
|
|
@@ -68,19 +72,20 @@ module Proxy
|
|
|
68
72
|
volume-mounts:
|
|
69
73
|
- src: #{File.join(Dir.pwd, Proxy::SETTINGS.foreman_ssl_cert)}
|
|
70
74
|
dest: /run/secrets/foreman_ssl_cert
|
|
71
|
-
options: Z,ro
|
|
72
75
|
- src: #{File.join(Dir.pwd, Proxy::SETTINGS.foreman_ssl_key)}
|
|
73
76
|
dest: /run/secrets/foreman_ssl_key
|
|
74
|
-
options: Z,ro
|
|
75
77
|
- src: #{File.join(Dir.pwd, Proxy::SETTINGS.foreman_ssl_ca)}
|
|
76
78
|
dest: /run/secrets/foreman_ssl_verify
|
|
77
|
-
|
|
79
|
+
- src: #{proxy_ssh_key_path}
|
|
80
|
+
dest: #{proxy_ssh_key_mount_path}
|
|
78
81
|
logging:
|
|
79
82
|
level: debug
|
|
83
|
+
file: #{@runner_workdir}/ansible-navigator.log
|
|
80
84
|
mode: stdout
|
|
81
85
|
EOF
|
|
82
86
|
|
|
83
|
-
|
|
87
|
+
cd #{@runner_workdir}/
|
|
88
|
+
ansible-navigator run --private-key=#{proxy_ssh_key_mount_path}
|
|
84
89
|
CMD
|
|
85
90
|
initialize_command('bash', '-c', cmd)
|
|
86
91
|
end
|
|
@@ -0,0 +1,85 @@
|
|
|
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
|
+
PHASES = [
|
|
10
|
+
{ id: :build_ee, title: 'Building execution environment', runner_class: AnsibleBuilderRunner,
|
|
11
|
+
runner_input_key: :build_ee_input },
|
|
12
|
+
{ id: :run_ansible, title: 'Running Ansible', runner_class: AnsibleNavigatorRunner,
|
|
13
|
+
runner_input_key: :run_ansible_input }
|
|
14
|
+
].freeze
|
|
15
|
+
|
|
16
|
+
def initialize(input, suspended_action: nil)
|
|
17
|
+
super(suspended_action: suspended_action)
|
|
18
|
+
@input = input
|
|
19
|
+
@phase_index = 0
|
|
20
|
+
@current_runner = nil
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def start
|
|
24
|
+
transition_to_phase(@phase_index)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def refresh
|
|
28
|
+
return unless @current_runner
|
|
29
|
+
|
|
30
|
+
@current_runner.refresh
|
|
31
|
+
|
|
32
|
+
@continuous_output.raw_outputs.concat(@current_runner.continuous_output.raw_outputs)
|
|
33
|
+
@current_runner.continuous_output.raw_outputs.clear
|
|
34
|
+
|
|
35
|
+
return unless @current_runner.exit_status
|
|
36
|
+
|
|
37
|
+
if @current_runner.exit_status != 0
|
|
38
|
+
publish_exit_status(@current_runner.exit_status)
|
|
39
|
+
else
|
|
40
|
+
transition_to_next_phase
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def kill
|
|
45
|
+
@current_runner&.kill
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def close
|
|
49
|
+
@current_runner&.close
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
private
|
|
53
|
+
|
|
54
|
+
def transition_to_phase(index)
|
|
55
|
+
phase_info = PHASES[index]
|
|
56
|
+
|
|
57
|
+
@phase_index = index
|
|
58
|
+
runner_class = phase_info[:runner_class]
|
|
59
|
+
runner_input = @input[phase_info[:runner_input_key]]
|
|
60
|
+
|
|
61
|
+
@continuous_output.add_output(
|
|
62
|
+
"START: Phase #{phase_info[:id]} (#{index + 1} / #{PHASES.length}): #{phase_info[:title]}\n"
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
@current_runner = runner_class.new(runner_input, suspended_action: @suspended_action)
|
|
66
|
+
@current_runner.start
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def transition_to_next_phase
|
|
70
|
+
phase_info = PHASES[@phase_index]
|
|
71
|
+
@continuous_output.add_output(
|
|
72
|
+
"END: Phase #{phase_info[:id]}: #{phase_info[:title]}\n"
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
if @phase_index + 1 < PHASES.length
|
|
76
|
+
@phase_index += 1
|
|
77
|
+
transition_to_phase(@phase_index)
|
|
78
|
+
else
|
|
79
|
+
publish_exit_status(0)
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
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.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- ATIX AG
|
|
@@ -13,16 +13,42 @@ dependencies:
|
|
|
13
13
|
name: smart_proxy_dynflow
|
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
|
15
15
|
requirements:
|
|
16
|
-
- - "
|
|
16
|
+
- - ">="
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: 0.9.4
|
|
19
|
+
- - "<"
|
|
17
20
|
- !ruby/object:Gem::Version
|
|
18
|
-
version:
|
|
21
|
+
version: 2.0.0
|
|
19
22
|
type: :runtime
|
|
20
23
|
prerelease: false
|
|
21
24
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
25
|
requirements:
|
|
23
|
-
- - "
|
|
26
|
+
- - ">="
|
|
27
|
+
- !ruby/object:Gem::Version
|
|
28
|
+
version: 0.9.4
|
|
29
|
+
- - "<"
|
|
30
|
+
- !ruby/object:Gem::Version
|
|
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
|
+
- - "<"
|
|
24
50
|
- !ruby/object:Gem::Version
|
|
25
|
-
version:
|
|
51
|
+
version: 2.0.0
|
|
26
52
|
- !ruby/object:Gem::Dependency
|
|
27
53
|
name: mocha
|
|
28
54
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -97,6 +123,7 @@ files:
|
|
|
97
123
|
- lib/smart_proxy_ansible_director/runners.rb
|
|
98
124
|
- lib/smart_proxy_ansible_director/runners/ansible_builder_runner.rb
|
|
99
125
|
- lib/smart_proxy_ansible_director/runners/ansible_navigator_runner.rb
|
|
126
|
+
- lib/smart_proxy_ansible_director/runners/meta_runner.rb
|
|
100
127
|
- lib/smart_proxy_ansible_director/runners/podman_pull_runner.rb
|
|
101
128
|
- lib/smart_proxy_ansible_director/runners/podman_push_runner.rb
|
|
102
129
|
- lib/smart_proxy_ansible_director/version.rb
|
|
@@ -122,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
122
149
|
- !ruby/object:Gem::Version
|
|
123
150
|
version: '0'
|
|
124
151
|
requirements: []
|
|
125
|
-
rubygems_version: 4.0.
|
|
152
|
+
rubygems_version: 4.0.10
|
|
126
153
|
specification_version: 4
|
|
127
154
|
summary: Smart Proxy plugin to integrate Ansible Director with Foreman
|
|
128
155
|
test_files: []
|