smart_proxy_ansible_director 0.2.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 +7 -0
- data/LICENSE +675 -0
- data/README.md +35 -0
- data/bundler.d/ansible_director.rb +3 -0
- data/lib/smart_proxy_ansible_director/actions/build_execution_environment.rb +23 -0
- data/lib/smart_proxy_ansible_director/actions/meta/build_push_ee.rb +58 -0
- data/lib/smart_proxy_ansible_director/actions/meta/run_ansible_script.rb +35 -0
- data/lib/smart_proxy_ansible_director/actions/meta/run_playbook.rb +46 -0
- data/lib/smart_proxy_ansible_director/actions/pull_execution_environment.rb +17 -0
- data/lib/smart_proxy_ansible_director/actions/push_execution_environment.rb +17 -0
- data/lib/smart_proxy_ansible_director/actions/run_ansible_navigator.rb +17 -0
- data/lib/smart_proxy_ansible_director/actions.rb +13 -0
- data/lib/smart_proxy_ansible_director/api.rb +20 -0
- data/lib/smart_proxy_ansible_director/helpers/ansible_navigator_helpers.rb +23 -0
- data/lib/smart_proxy_ansible_director/helpers/execution_environment_helpers.rb +47 -0
- data/lib/smart_proxy_ansible_director/http_config.ru +7 -0
- data/lib/smart_proxy_ansible_director/launchers/ansible_builder_launcher.rb +12 -0
- data/lib/smart_proxy_ansible_director/launchers/ansible_navigator_launcher.rb +12 -0
- data/lib/smart_proxy_ansible_director/launchers/meta_launcher.rb +12 -0
- data/lib/smart_proxy_ansible_director/launchers.rb +11 -0
- data/lib/smart_proxy_ansible_director/plugin.rb +36 -0
- data/lib/smart_proxy_ansible_director/runners/ansible_builder_runner.rb +112 -0
- data/lib/smart_proxy_ansible_director/runners/ansible_navigator_runner.rb +110 -0
- data/lib/smart_proxy_ansible_director/runners/podman_pull_runner.rb +32 -0
- data/lib/smart_proxy_ansible_director/runners/podman_push_runner.rb +38 -0
- data/lib/smart_proxy_ansible_director/runners.rb +12 -0
- data/lib/smart_proxy_ansible_director/version.rb +7 -0
- data/lib/smart_proxy_ansible_director.rb +8 -0
- data/settings.d/ansible_director.yml.example +2 -0
- metadata +128 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'smart_proxy_dynflow/runner/process_manager_command'
|
|
4
|
+
require_relative '../helpers/ansible_navigator_helpers'
|
|
5
|
+
require 'yaml'
|
|
6
|
+
|
|
7
|
+
module Proxy
|
|
8
|
+
module AnsibleDirector
|
|
9
|
+
module Runners
|
|
10
|
+
class AnsibleNavigatorRunner < ::Proxy::Dynflow::Runner::Base
|
|
11
|
+
include ::Proxy::Dynflow::Runner::ProcessManagerCommand
|
|
12
|
+
|
|
13
|
+
def initialize(ansible_input, suspended_action: nil)
|
|
14
|
+
super suspended_action: suspended_action
|
|
15
|
+
@inventory = ::Proxy::AnsibleDirector::Helpers::AnsibleNavigatorHelpers.reserialize_inventory(ansible_input[:inventory])
|
|
16
|
+
if ansible_input[:mode] == 'literal'
|
|
17
|
+
@playbook = ansible_input[:playbook]
|
|
18
|
+
@variables = {}
|
|
19
|
+
else
|
|
20
|
+
@playbook = ::Proxy::AnsibleDirector::Helpers::AnsibleNavigatorHelpers.reserialize_playbook(ansible_input[:playbook])
|
|
21
|
+
@variables = ansible_input[:variables]
|
|
22
|
+
end
|
|
23
|
+
@execution_environment = ansible_input[:execution_environment]
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def start
|
|
27
|
+
# TODO: Find a way to request the auth token programmatically
|
|
28
|
+
cmd = <<~CMD
|
|
29
|
+
|
|
30
|
+
TMPDIR=$(mktemp -d /tmp/ansible-run_XXXXXX)
|
|
31
|
+
echo $TMPDIR
|
|
32
|
+
cd $TMPDIR#{' '}
|
|
33
|
+
|
|
34
|
+
cat > "playbook.yaml" <<'EOF'
|
|
35
|
+
#{@playbook}
|
|
36
|
+
EOF
|
|
37
|
+
|
|
38
|
+
cat > "inventory.yaml" <<'EOF'
|
|
39
|
+
#{@inventory}
|
|
40
|
+
EOF
|
|
41
|
+
|
|
42
|
+
mkdir vars
|
|
43
|
+
|
|
44
|
+
#{
|
|
45
|
+
@variables.map do |role_name, variables|
|
|
46
|
+
%(cat > "vars/#{role_name}_vars.yaml" <<'EOF'\n#{format_variables role_name, variables}EOF)
|
|
47
|
+
end.join("\n\n")
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
cat > "ansible-navigator.yaml" <<'EOF'
|
|
51
|
+
---
|
|
52
|
+
ansible-navigator:
|
|
53
|
+
ansible:
|
|
54
|
+
inventory:
|
|
55
|
+
entries:
|
|
56
|
+
- ./inventory.yaml
|
|
57
|
+
playbook:
|
|
58
|
+
path: ./playbook.yaml
|
|
59
|
+
execution-environment:
|
|
60
|
+
image: #{@execution_environment}
|
|
61
|
+
pull:
|
|
62
|
+
arguments:
|
|
63
|
+
- "--tls-verify=false"
|
|
64
|
+
- "--authfile=$AUTHFILE"
|
|
65
|
+
policy: missing
|
|
66
|
+
volume-mounts:
|
|
67
|
+
- src: #{File.join(Dir.pwd, Proxy::SETTINGS.foreman_ssl_cert)}
|
|
68
|
+
dest: /run/secrets/foreman_ssl_cert
|
|
69
|
+
options: Z,ro
|
|
70
|
+
- src: #{File.join(Dir.pwd, Proxy::SETTINGS.foreman_ssl_key)}
|
|
71
|
+
dest: /run/secrets/foreman_ssl_key
|
|
72
|
+
options: Z,ro
|
|
73
|
+
- src: #{File.join(Dir.pwd, Proxy::SETTINGS.foreman_ssl_ca)}
|
|
74
|
+
dest: /run/secrets/foreman_ssl_verify
|
|
75
|
+
options: Z,ro
|
|
76
|
+
logging:
|
|
77
|
+
level: debug
|
|
78
|
+
mode: stdout
|
|
79
|
+
EOF
|
|
80
|
+
|
|
81
|
+
ansible-navigator run --mode stdout
|
|
82
|
+
CMD
|
|
83
|
+
initialize_command('bash', '-c', cmd)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def refresh
|
|
87
|
+
@process_manager.process(timeout: 0.1) unless @process_manager.done?
|
|
88
|
+
puts @continuous_output.humanize
|
|
89
|
+
publish_exit_status(@process_manager.status) if @process_manager.done?
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
private
|
|
93
|
+
|
|
94
|
+
def format_variables(_role_name, variables)
|
|
95
|
+
formatted = {}
|
|
96
|
+
variables.each do |k, v|
|
|
97
|
+
formatted_v = begin
|
|
98
|
+
YAML.safe_load v
|
|
99
|
+
rescue Exception
|
|
100
|
+
v
|
|
101
|
+
end
|
|
102
|
+
formatted[k] = formatted_v
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
formatted.to_h.to_yaml
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'smart_proxy_dynflow/runner/process_manager_command'
|
|
4
|
+
require_relative '../helpers/ansible_navigator_helpers'
|
|
5
|
+
|
|
6
|
+
module Proxy
|
|
7
|
+
module AnsibleDirector
|
|
8
|
+
module Runners
|
|
9
|
+
class PodmanPullRunner < ::Proxy::Dynflow::Runner::Base
|
|
10
|
+
include ::Proxy::Dynflow::Runner::ProcessManagerCommand
|
|
11
|
+
|
|
12
|
+
def initialize(podman_pull_input, suspended_action: nil)
|
|
13
|
+
super suspended_action: suspended_action
|
|
14
|
+
@ee_registry_url = podman_pull_input[:ee_registry_url]
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def start
|
|
18
|
+
cmd = <<~CMD
|
|
19
|
+
podman pull --tls-verify=false #{@ee_registry_url}
|
|
20
|
+
CMD
|
|
21
|
+
initialize_command('bash', '-c', cmd)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def refresh
|
|
25
|
+
@process_manager.process(timeout: 0.1) unless @process_manager.done?
|
|
26
|
+
puts @continuous_output.humanize
|
|
27
|
+
publish_exit_status(@process_manager.status) if @process_manager.done?
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'smart_proxy_dynflow/runner/process_manager_command'
|
|
4
|
+
require_relative '../helpers/ansible_navigator_helpers'
|
|
5
|
+
|
|
6
|
+
module Proxy
|
|
7
|
+
module AnsibleDirector
|
|
8
|
+
module Runners
|
|
9
|
+
class PodmanPushRunner < ::Proxy::Dynflow::Runner::Base
|
|
10
|
+
include ::Proxy::Dynflow::Runner::ProcessManagerCommand
|
|
11
|
+
|
|
12
|
+
def initialize(podman_push_input, suspended_action: nil)
|
|
13
|
+
super suspended_action: suspended_action
|
|
14
|
+
puts podman_push_input
|
|
15
|
+
@ee_id = podman_push_input[:ee_id]
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def start
|
|
19
|
+
# TODO: Parametrize
|
|
20
|
+
|
|
21
|
+
image_name = "ansibleng/#{@ee_id}:latest"
|
|
22
|
+
registry = 'centos9-katello-devel-stable.example.com:4321'
|
|
23
|
+
|
|
24
|
+
cmd = <<~CMD
|
|
25
|
+
podman push --tls-verify=false #{image_name} #{registry}/#{image_name}
|
|
26
|
+
CMD
|
|
27
|
+
initialize_command('bash', '-c', cmd)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def refresh
|
|
31
|
+
@process_manager.process(timeout: 0.1) unless @process_manager.done?
|
|
32
|
+
puts @continuous_output.humanize
|
|
33
|
+
publish_exit_status(@process_manager.status) if @process_manager.done?
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Proxy
|
|
4
|
+
module AnsibleDirector
|
|
5
|
+
module Runners
|
|
6
|
+
require 'smart_proxy_ansible_director/runners/ansible_builder_runner'
|
|
7
|
+
require 'smart_proxy_ansible_director/runners/ansible_navigator_runner'
|
|
8
|
+
require 'smart_proxy_ansible_director/runners/podman_push_runner'
|
|
9
|
+
require 'smart_proxy_ansible_director/runners/podman_pull_runner'
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: smart_proxy_ansible_director
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.2.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- ATIX AG
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 2026-02-11 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: smart_proxy_dynflow
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - "~>"
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '0.9'
|
|
19
|
+
type: :runtime
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - "~>"
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: '0.9'
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
27
|
+
name: mocha
|
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - "~>"
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '2.8'
|
|
33
|
+
type: :development
|
|
34
|
+
prerelease: false
|
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - "~>"
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '2.8'
|
|
40
|
+
- !ruby/object:Gem::Dependency
|
|
41
|
+
name: rake
|
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
|
43
|
+
requirements:
|
|
44
|
+
- - "~>"
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '13.3'
|
|
47
|
+
type: :development
|
|
48
|
+
prerelease: false
|
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - "~>"
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '13.3'
|
|
54
|
+
- !ruby/object:Gem::Dependency
|
|
55
|
+
name: test-unit
|
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
|
57
|
+
requirements:
|
|
58
|
+
- - "~>"
|
|
59
|
+
- !ruby/object:Gem::Version
|
|
60
|
+
version: '3.7'
|
|
61
|
+
type: :development
|
|
62
|
+
prerelease: false
|
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
64
|
+
requirements:
|
|
65
|
+
- - "~>"
|
|
66
|
+
- !ruby/object:Gem::Version
|
|
67
|
+
version: '3.7'
|
|
68
|
+
description: This plugin adds support for the Ansible Director to Foreman's Smart
|
|
69
|
+
Proxy
|
|
70
|
+
email:
|
|
71
|
+
- info@atix.de
|
|
72
|
+
executables: []
|
|
73
|
+
extensions: []
|
|
74
|
+
extra_rdoc_files: []
|
|
75
|
+
files:
|
|
76
|
+
- LICENSE
|
|
77
|
+
- README.md
|
|
78
|
+
- bundler.d/ansible_director.rb
|
|
79
|
+
- lib/smart_proxy_ansible_director.rb
|
|
80
|
+
- lib/smart_proxy_ansible_director/actions.rb
|
|
81
|
+
- lib/smart_proxy_ansible_director/actions/build_execution_environment.rb
|
|
82
|
+
- lib/smart_proxy_ansible_director/actions/meta/build_push_ee.rb
|
|
83
|
+
- lib/smart_proxy_ansible_director/actions/meta/run_ansible_script.rb
|
|
84
|
+
- lib/smart_proxy_ansible_director/actions/meta/run_playbook.rb
|
|
85
|
+
- lib/smart_proxy_ansible_director/actions/pull_execution_environment.rb
|
|
86
|
+
- lib/smart_proxy_ansible_director/actions/push_execution_environment.rb
|
|
87
|
+
- lib/smart_proxy_ansible_director/actions/run_ansible_navigator.rb
|
|
88
|
+
- lib/smart_proxy_ansible_director/api.rb
|
|
89
|
+
- lib/smart_proxy_ansible_director/helpers/ansible_navigator_helpers.rb
|
|
90
|
+
- lib/smart_proxy_ansible_director/helpers/execution_environment_helpers.rb
|
|
91
|
+
- lib/smart_proxy_ansible_director/http_config.ru
|
|
92
|
+
- lib/smart_proxy_ansible_director/launchers.rb
|
|
93
|
+
- lib/smart_proxy_ansible_director/launchers/ansible_builder_launcher.rb
|
|
94
|
+
- lib/smart_proxy_ansible_director/launchers/ansible_navigator_launcher.rb
|
|
95
|
+
- lib/smart_proxy_ansible_director/launchers/meta_launcher.rb
|
|
96
|
+
- lib/smart_proxy_ansible_director/plugin.rb
|
|
97
|
+
- lib/smart_proxy_ansible_director/runners.rb
|
|
98
|
+
- lib/smart_proxy_ansible_director/runners/ansible_builder_runner.rb
|
|
99
|
+
- lib/smart_proxy_ansible_director/runners/ansible_navigator_runner.rb
|
|
100
|
+
- lib/smart_proxy_ansible_director/runners/podman_pull_runner.rb
|
|
101
|
+
- lib/smart_proxy_ansible_director/runners/podman_push_runner.rb
|
|
102
|
+
- lib/smart_proxy_ansible_director/version.rb
|
|
103
|
+
- settings.d/ansible_director.yml.example
|
|
104
|
+
homepage: https://github.com/ATIX-AG/smart_proxy_ansible_director
|
|
105
|
+
licenses:
|
|
106
|
+
- GPL-3.0-only
|
|
107
|
+
metadata: {}
|
|
108
|
+
rdoc_options: []
|
|
109
|
+
require_paths:
|
|
110
|
+
- lib
|
|
111
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
112
|
+
requirements:
|
|
113
|
+
- - ">="
|
|
114
|
+
- !ruby/object:Gem::Version
|
|
115
|
+
version: '3.0'
|
|
116
|
+
- - "<"
|
|
117
|
+
- !ruby/object:Gem::Version
|
|
118
|
+
version: '4'
|
|
119
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
|
+
requirements:
|
|
121
|
+
- - ">="
|
|
122
|
+
- !ruby/object:Gem::Version
|
|
123
|
+
version: '0'
|
|
124
|
+
requirements: []
|
|
125
|
+
rubygems_version: 3.6.3
|
|
126
|
+
specification_version: 4
|
|
127
|
+
summary: Smart Proxy plugin to integrate Ansible Director with Foreman
|
|
128
|
+
test_files: []
|