smart_proxy_acd 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -1
- data/lib/smart_proxy_acd/acd.rb +2 -0
- data/lib/smart_proxy_acd/acd_main.rb +11 -0
- data/lib/smart_proxy_acd/acd_runner.rb +15 -41
- data/lib/smart_proxy_acd/acd_task_launcher.rb +2 -0
- data/lib/smart_proxy_acd/version.rb +1 -1
- data/settings.d/acd.yml.example +2 -0
- 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: 183250a25f2479402b6eb73acd841ec985da00ebe17cb4b836df7b1e3d37ae48
|
4
|
+
data.tar.gz: d9b0c52df1fad8c9a998930252617eb971a8319a3f53fdd0e910b17bcef8b439
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88664606e79721dc883ee637bf749f54d6bfd3481ba42366abb4c0725a727fad4ec94d1029b25f0142b889b6bcdbde07f6e1142f419a939e8b3d4ae9ccddc5fa
|
7
|
+
data.tar.gz: 23cc133598f5d3888e0298bf5b2c3786d6a429ff6ba3625d673efdc0f61f338e64d749811c8dcbab8ff0cce544d7ec5672c813dbb38492cf2293f16d59c30f33
|
data/README.md
CHANGED
@@ -14,7 +14,6 @@ This plug-in adds support for [Application Centric Deployment](https://github.co
|
|
14
14
|
|
15
15
|
We expect your proxy to also have
|
16
16
|
[smart_proxy_dynflow](https://github.com/theforeman/smart_proxy_dynflow)
|
17
|
-
and [foreman-tasks-core](https://github.com/theforeman/foreman-tasks) as
|
18
17
|
a gem requirement.
|
19
18
|
|
20
19
|
### Get the code
|
data/lib/smart_proxy_acd/acd.rb
CHANGED
@@ -13,6 +13,8 @@ module Proxy
|
|
13
13
|
require 'smart_proxy_acd/acd_task_launcher'
|
14
14
|
end
|
15
15
|
|
16
|
+
default_settings :timeout => 60
|
17
|
+
|
16
18
|
load_dependency_injection_wirings do |_container_instance, _settings|
|
17
19
|
Proxy::Dynflow::TaskLauncherRegistry.register('acd', AcdTaskLauncher)
|
18
20
|
end
|
@@ -5,6 +5,17 @@ module Proxy
|
|
5
5
|
extend ::Proxy::Log
|
6
6
|
|
7
7
|
class << self
|
8
|
+
def plugin_settings
|
9
|
+
# rubocop:disable ClassVars
|
10
|
+
@@settings ||= OpenStruct.new(read_settings)
|
11
|
+
# rubocop:enable ClassVars
|
12
|
+
end
|
13
|
+
|
14
|
+
def read_settings
|
15
|
+
::Proxy::Acd::Plugin.default_settings.merge(
|
16
|
+
YAML.load_file(File.join(::Proxy::SETTINGS.settings_directory, ::Proxy::Acd::Plugin.settings_file))
|
17
|
+
)
|
18
|
+
end
|
8
19
|
end
|
9
20
|
end
|
10
21
|
end
|
@@ -1,8 +1,10 @@
|
|
1
|
+
require 'smart_proxy_dynflow/runner/base'
|
1
2
|
require 'smart_proxy_dynflow/runner/command_runner'
|
2
3
|
require 'tempfile'
|
3
4
|
require 'rest-client'
|
4
5
|
require 'tmpdir'
|
5
6
|
require 'socket'
|
7
|
+
require 'proxy/request'
|
6
8
|
|
7
9
|
# rubocop:disable ClassLength
|
8
10
|
|
@@ -12,42 +14,6 @@ module Proxy
|
|
12
14
|
class AcdRunner < Proxy::Dynflow::Runner::CommandRunner
|
13
15
|
DEFAULT_REFRESH_INTERVAL = 1
|
14
16
|
|
15
|
-
class << self
|
16
|
-
def parse_dynflow_settings(path)
|
17
|
-
return @dynflow_settings if defined? @dynflow_settings
|
18
|
-
if File.exist?(path)
|
19
|
-
@dynflow_settings = {}
|
20
|
-
YAML.load_file(path).each do |key, value|
|
21
|
-
@dynflow_settings[key.to_s] = value
|
22
|
-
end
|
23
|
-
end
|
24
|
-
@dynflow_settings
|
25
|
-
end
|
26
|
-
|
27
|
-
def parse_ssl_options
|
28
|
-
return @ssl_options if defined? @ssl_options
|
29
|
-
|
30
|
-
@ssl_options = {}
|
31
|
-
return @ssl_options unless URI.parse(@dynflow_settings['foreman_url']).scheme == 'https'
|
32
|
-
|
33
|
-
@ssl_options[:verify_ssl] = OpenSSL::SSL::VERIFY_PEER
|
34
|
-
|
35
|
-
private_key_file = @dynflow_settings['foreman_ssl_key'] || @dynflow_settings['ssl_private_key']
|
36
|
-
if private_key_file
|
37
|
-
private_key = File.read(private_key_file)
|
38
|
-
@ssl_options[:ssl_client_key] = OpenSSL::PKey::RSA.new(private_key)
|
39
|
-
end
|
40
|
-
certificate_file = @dynflow_settings['foreman_ssl_cert'] || @dynflow_settings['ssl_certificate']
|
41
|
-
if certificate_file
|
42
|
-
certificate = File.read(certificate_file)
|
43
|
-
@ssl_options[:ssl_client_cert] = OpenSSL::X509::Certificate.new(certificate)
|
44
|
-
end
|
45
|
-
ca_file = @dynflow_settings['foreman_ssl_ca'] || @dynflow_settings['ssl_ca_file']
|
46
|
-
@ssl_options[:ssl_ca_file] = ca_file if ca_file
|
47
|
-
@ssl_options
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
17
|
def initialize(options, suspended_action:)
|
52
18
|
super(options, :suspended_action => suspended_action)
|
53
19
|
@options = options
|
@@ -55,19 +21,21 @@ module Proxy
|
|
55
21
|
|
56
22
|
def get_playbook(playbook_id)
|
57
23
|
logger.debug("Get playbook with id #{playbook_id}")
|
58
|
-
response = playbook_resource(playbook_id)
|
24
|
+
response = playbook_resource(playbook_id)
|
59
25
|
if response.code.to_s != '200'
|
60
26
|
raise "Failed performing callback to Foreman server: #{response.code} #{response.body}"
|
61
27
|
end
|
62
28
|
tmp_file = Tempfile.new.path
|
63
|
-
File.write(tmp_file, response)
|
29
|
+
File.write(tmp_file, response.body)
|
64
30
|
@playbook_tmp_base64_file = tmp_file
|
65
31
|
end
|
66
32
|
|
67
33
|
def playbook_resource(playbook_id)
|
68
|
-
|
69
|
-
|
70
|
-
|
34
|
+
playbook_download_path = "/acd/api/v2/ansible_playbooks/#{playbook_id}/grab"
|
35
|
+
foreman_request = Proxy::HttpRequest::ForemanRequest.new
|
36
|
+
req = foreman_request.request_factory.create_get(playbook_download_path)
|
37
|
+
foreman_request.http.read_timeout = Proxy::Acd::Plugin.settings.timeout
|
38
|
+
foreman_request.send_request(req)
|
71
39
|
end
|
72
40
|
|
73
41
|
def store_playbook
|
@@ -133,6 +101,12 @@ module Proxy
|
|
133
101
|
complete_inventory = YAML.safe_load(@acd_job['inventory'])
|
134
102
|
my_inventory = complete_inventory[proxy_hostname]
|
135
103
|
|
104
|
+
my_inventory['all']['children'].each_value do |group|
|
105
|
+
group['hosts'].each_value do |host_vars|
|
106
|
+
host_vars['ansible_ssh_private_key_file'] ||= Proxy::RemoteExecution::Ssh::Plugin.settings[:ssh_identity_key_file]
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
136
110
|
tmp_inventory_file = Tempfile.new('acd_inventory')
|
137
111
|
tmp_inventory_file << my_inventory.to_yaml
|
138
112
|
tmp_inventory_file << "\n"
|
data/settings.d/acd.yml.example
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smart_proxy_acd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Markus Bucher
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-07-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|