smart_proxy_salt 5.0.1 → 6.0.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/bin/foreman-node +6 -3
- data/lib/smart_proxy_salt/cli.rb +5 -7
- data/lib/smart_proxy_salt/rest.rb +1 -0
- data/lib/smart_proxy_salt/salt.rb +5 -5
- data/lib/smart_proxy_salt/salt_runner.rb +2 -0
- data/lib/smart_proxy_salt/salt_task_launcher.rb +2 -0
- data/lib/smart_proxy_salt/version.rb +1 -1
- data/salt/minion_auth/srv/salt/_runners/foreman_https.py +2 -2
- data/salt/report_upload/srv/salt/_runners/foreman_report_upload.py +12 -26
- data/sbin/upload-salt-reports +2 -2
- metadata +15 -96
- data/bin/salt_python_wrapper +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd14287d87c9ed2e41a86539f25b52f741549f20501b5f6dc7936075cca3fdad
|
4
|
+
data.tar.gz: af25b8597c836c1b5a8fd726612f6c49d05a87b50e877c19f42e2836d97c1717
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ecdaa039f92b673ab76340da06d92397d01980baf5c7956687cd2314ff1e8e579af6beed07f1a966312c285adc30606895a3c1545ffb0e38b8a68bc087328b76
|
7
|
+
data.tar.gz: 23853c34472f6cbb3a674c5c88806167c5f6be692032ecc08a474ae335ad842e477ce8425a8ef35787878b51128bad278bf90bca014b3fbc5c6937062e297889
|
data/bin/foreman-node
CHANGED
@@ -45,7 +45,7 @@ end
|
|
45
45
|
|
46
46
|
def get_grains(minion)
|
47
47
|
grains = {
|
48
|
-
:name
|
48
|
+
:name => minion,
|
49
49
|
:facts => plain_grains(minion).merge(:_timestamp => Time.now, :_type => 'foreman_salt')
|
50
50
|
}
|
51
51
|
|
@@ -94,9 +94,10 @@ end
|
|
94
94
|
def plainify(hash, prefix = nil)
|
95
95
|
result = []
|
96
96
|
hash.each_pair do |key, value|
|
97
|
-
|
97
|
+
case value
|
98
|
+
when Hash
|
98
99
|
result.push plainify(value, get_key(key, prefix))
|
99
|
-
|
100
|
+
when Array
|
100
101
|
result.push plainify(array_to_hash(value), get_key(key, prefix))
|
101
102
|
else
|
102
103
|
new = {}
|
@@ -169,12 +170,14 @@ def enc(minion)
|
|
169
170
|
res = http.start { |conn| conn.request(req) }
|
170
171
|
|
171
172
|
raise "Error retrieving node #{minion}: #{res.class}\nCheck Foreman's /var/log/foreman/production.log for more information." unless res.code == '200'
|
173
|
+
|
172
174
|
res.body
|
173
175
|
end
|
174
176
|
|
175
177
|
minion = ARGV[0] || raise('Must provide minion as an argument')
|
176
178
|
|
177
179
|
raise 'Invalid hostname' unless valid_hostname? minion
|
180
|
+
|
178
181
|
begin
|
179
182
|
result = ''
|
180
183
|
|
data/lib/smart_proxy_salt/cli.rb
CHANGED
@@ -56,16 +56,15 @@ module Proxy
|
|
56
56
|
|
57
57
|
def autosign_list
|
58
58
|
return [] unless File.exist?(autosign_file)
|
59
|
+
|
59
60
|
File.read(autosign_file).split("\n").reject do |v|
|
60
61
|
v =~ /^\s*#.*|^$/ ## Remove comments and empty lines
|
61
62
|
end.map(&:chomp)
|
62
63
|
end
|
63
64
|
|
64
65
|
def append_value_to_file(filepath, value)
|
65
|
-
File.open(filepath, File::CREAT|File::RDWR) do |file|
|
66
|
-
unless file.any? { |line| line.chomp == value}
|
67
|
-
file.puts value
|
68
|
-
end
|
66
|
+
File.open(filepath, File::CREAT | File::RDWR) do |file|
|
67
|
+
file.puts value unless file.any? { |line| line.chomp == value }
|
69
68
|
end
|
70
69
|
logger.info "Added an entry to '#{filepath}' successfully."
|
71
70
|
true
|
@@ -75,7 +74,6 @@ module Proxy
|
|
75
74
|
end
|
76
75
|
|
77
76
|
def remove_value_from_file(filepath, value)
|
78
|
-
|
79
77
|
return true unless File.exist?(filepath)
|
80
78
|
|
81
79
|
found = false
|
@@ -84,14 +82,14 @@ module Proxy
|
|
84
82
|
if entry == value
|
85
83
|
found = true
|
86
84
|
nil
|
87
|
-
elsif entry ==
|
85
|
+
elsif entry == ''
|
88
86
|
nil
|
89
87
|
else
|
90
88
|
line
|
91
89
|
end
|
92
90
|
end.uniq.compact
|
93
91
|
if found
|
94
|
-
File.write(filepath, entries.join
|
92
|
+
File.write(filepath, entries.join)
|
95
93
|
logger.info "Removed an entry from '#{filepath}' successfully."
|
96
94
|
end
|
97
95
|
true
|
@@ -12,11 +12,11 @@ module Proxy
|
|
12
12
|
class Plugin < ::Proxy::Plugin
|
13
13
|
plugin 'salt', Proxy::Salt::VERSION
|
14
14
|
|
15
|
-
default_settings :autosign_file
|
16
|
-
:autosign_key_file
|
17
|
-
:salt_command_user
|
18
|
-
:use_api
|
19
|
-
:saltfile
|
15
|
+
default_settings :autosign_file => '/etc/salt/autosign.conf',
|
16
|
+
:autosign_key_file => '/var/lib/foreman-proxy/salt/grains/autosign_key',
|
17
|
+
:salt_command_user => 'root',
|
18
|
+
:use_api => false,
|
19
|
+
:saltfile => '/etc/foreman-proxy/settings.d/salt.saltfile'
|
20
20
|
|
21
21
|
requires :dynflow, '>= 0.5.0'
|
22
22
|
|
@@ -19,8 +19,8 @@ def salt_config():
|
|
19
19
|
"""
|
20
20
|
Read the foreman configuratoin from FOREMAN_CONFIG
|
21
21
|
"""
|
22
|
-
with open(FOREMAN_CONFIG
|
23
|
-
config = yaml.
|
22
|
+
with open(FOREMAN_CONFIG) as config_file:
|
23
|
+
config = yaml.safe_load(config_file.read())
|
24
24
|
return config
|
25
25
|
|
26
26
|
|
@@ -1,45 +1,32 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
1
|
'''
|
3
2
|
Uploads reports from the Salt job cache to Foreman
|
4
3
|
'''
|
5
|
-
from __future__ import absolute_import, print_function, unicode_literals
|
6
4
|
|
7
|
-
|
8
|
-
FOREMAN_CONFIG = '/etc/salt/foreman.yaml'
|
9
|
-
LOCK_FILE = '/var/lock/salt-report-upload.lock'
|
5
|
+
from http.client import HTTPConnection, HTTPSConnection
|
10
6
|
|
11
|
-
try:
|
12
|
-
from http.client import HTTPConnection, HTTPSConnection
|
13
|
-
except ImportError:
|
14
|
-
from httplib import HTTPSConnection, HTTPSConnection
|
15
|
-
|
16
|
-
import io
|
17
7
|
import ssl
|
18
8
|
import json
|
19
9
|
import yaml
|
20
10
|
import os
|
21
|
-
import sys
|
22
11
|
import base64
|
23
|
-
|
24
|
-
# Import python libs
|
25
12
|
import logging
|
26
13
|
|
27
|
-
|
28
|
-
|
14
|
+
LAST_UPLOADED = '/etc/salt/last_uploaded'
|
15
|
+
FOREMAN_CONFIG = '/etc/salt/foreman.yaml'
|
16
|
+
LOCK_FILE = '/var/lock/salt-report-upload.lock'
|
29
17
|
|
30
|
-
|
31
|
-
unicode = str
|
18
|
+
log = logging.getLogger(__name__)
|
32
19
|
|
33
20
|
|
34
21
|
def salt_config():
|
35
|
-
with open(FOREMAN_CONFIG
|
36
|
-
config = yaml.
|
22
|
+
with open(FOREMAN_CONFIG) as f:
|
23
|
+
config = yaml.safe_load(f.read())
|
37
24
|
return config
|
38
25
|
|
39
26
|
|
40
27
|
def write_last_uploaded(last_uploaded):
|
41
|
-
with
|
42
|
-
f.write(
|
28
|
+
with open(LAST_UPLOADED, 'w+') as f:
|
29
|
+
f.write(str(last_uploaded))
|
43
30
|
|
44
31
|
|
45
32
|
def upload(report):
|
@@ -51,7 +38,7 @@ def upload(report):
|
|
51
38
|
ctx = ssl.create_default_context()
|
52
39
|
ctx.load_cert_chain(certfile=config[':ssl_cert'], keyfile=config[':ssl_key'])
|
53
40
|
if config[':ssl_ca']:
|
54
|
-
|
41
|
+
ctx.load_verify_locations(cafile=config[':ssl_ca'])
|
55
42
|
connection = HTTPSConnection(config[':host'],
|
56
43
|
port=config[':port'], context=ctx)
|
57
44
|
else:
|
@@ -68,7 +55,7 @@ def upload(report):
|
|
68
55
|
|
69
56
|
if response.status == 200:
|
70
57
|
write_last_uploaded(report['job']['job_id'])
|
71
|
-
info_msg = 'Success {
|
58
|
+
info_msg = 'Success {}: {}'.format(report['job']['job_id'], response.read())
|
72
59
|
log.info(info_msg)
|
73
60
|
else:
|
74
61
|
log.error("Unable to upload job - aborting report upload")
|
@@ -107,7 +94,7 @@ def get_lock():
|
|
107
94
|
if os.path.isfile(LOCK_FILE):
|
108
95
|
raise Exception("Unable to obtain lock.")
|
109
96
|
else:
|
110
|
-
|
97
|
+
open(LOCK_FILE, 'w+').close()
|
111
98
|
|
112
99
|
|
113
100
|
def release_lock():
|
@@ -131,4 +118,3 @@ def now(highstate):
|
|
131
118
|
log.error('Exception encountered: %s', exc)
|
132
119
|
finally:
|
133
120
|
release_lock()
|
134
|
-
|
data/sbin/upload-salt-reports
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#!/usr/bin/
|
1
|
+
#!/usr/bin/python3
|
2
2
|
# Uploads reports from the Salt job cache to Foreman
|
3
3
|
|
4
4
|
from __future__ import print_function
|
@@ -28,7 +28,7 @@ if sys.version_info.major == 3:
|
|
28
28
|
|
29
29
|
def salt_config():
|
30
30
|
with io.open(FOREMAN_CONFIG, 'r') as f:
|
31
|
-
config = yaml.
|
31
|
+
config = yaml.safe_load(f.read())
|
32
32
|
return config
|
33
33
|
|
34
34
|
|
metadata
CHANGED
@@ -1,104 +1,22 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smart_proxy_salt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 6.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Moll
|
8
8
|
- Stephen Benjamin
|
9
|
-
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
requirements:
|
18
|
-
- - "~>"
|
19
|
-
- !ruby/object:Gem::Version
|
20
|
-
version: '2'
|
21
|
-
type: :development
|
22
|
-
prerelease: false
|
23
|
-
version_requirements: !ruby/object:Gem::Requirement
|
24
|
-
requirements:
|
25
|
-
- - "~>"
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
version: '2'
|
28
|
-
- !ruby/object:Gem::Dependency
|
29
|
-
name: mocha
|
30
|
-
requirement: !ruby/object:Gem::Requirement
|
31
|
-
requirements:
|
32
|
-
- - "~>"
|
33
|
-
- !ruby/object:Gem::Version
|
34
|
-
version: '1'
|
35
|
-
type: :development
|
36
|
-
prerelease: false
|
37
|
-
version_requirements: !ruby/object:Gem::Requirement
|
38
|
-
requirements:
|
39
|
-
- - "~>"
|
40
|
-
- !ruby/object:Gem::Version
|
41
|
-
version: '1'
|
42
|
-
- !ruby/object:Gem::Dependency
|
43
|
-
name: webmock
|
44
|
-
requirement: !ruby/object:Gem::Requirement
|
45
|
-
requirements:
|
46
|
-
- - "~>"
|
47
|
-
- !ruby/object:Gem::Version
|
48
|
-
version: '1'
|
49
|
-
type: :development
|
50
|
-
prerelease: false
|
51
|
-
version_requirements: !ruby/object:Gem::Requirement
|
52
|
-
requirements:
|
53
|
-
- - "~>"
|
54
|
-
- !ruby/object:Gem::Version
|
55
|
-
version: '1'
|
56
|
-
- !ruby/object:Gem::Dependency
|
57
|
-
name: rake
|
58
|
-
requirement: !ruby/object:Gem::Requirement
|
59
|
-
requirements:
|
60
|
-
- - "~>"
|
61
|
-
- !ruby/object:Gem::Version
|
62
|
-
version: '13'
|
63
|
-
type: :development
|
64
|
-
prerelease: false
|
65
|
-
version_requirements: !ruby/object:Gem::Requirement
|
66
|
-
requirements:
|
67
|
-
- - "~>"
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: '13'
|
70
|
-
- !ruby/object:Gem::Dependency
|
71
|
-
name: rubocop
|
72
|
-
requirement: !ruby/object:Gem::Requirement
|
73
|
-
requirements:
|
74
|
-
- - '='
|
75
|
-
- !ruby/object:Gem::Version
|
76
|
-
version: 0.50.0
|
77
|
-
type: :development
|
78
|
-
prerelease: false
|
79
|
-
version_requirements: !ruby/object:Gem::Requirement
|
80
|
-
requirements:
|
81
|
-
- - '='
|
82
|
-
- !ruby/object:Gem::Version
|
83
|
-
version: 0.50.0
|
84
|
-
- !ruby/object:Gem::Dependency
|
85
|
-
name: rack-test
|
14
|
+
name: smart_proxy_dynflow
|
86
15
|
requirement: !ruby/object:Gem::Requirement
|
87
16
|
requirements:
|
88
17
|
- - "~>"
|
89
18
|
- !ruby/object:Gem::Version
|
90
|
-
version: '0'
|
91
|
-
type: :development
|
92
|
-
prerelease: false
|
93
|
-
version_requirements: !ruby/object:Gem::Requirement
|
94
|
-
requirements:
|
95
|
-
- - "~>"
|
96
|
-
- !ruby/object:Gem::Version
|
97
|
-
version: '0'
|
98
|
-
- !ruby/object:Gem::Dependency
|
99
|
-
name: smart_proxy_dynflow
|
100
|
-
requirement: !ruby/object:Gem::Requirement
|
101
|
-
requirements:
|
19
|
+
version: '0.5'
|
102
20
|
- - ">="
|
103
21
|
- !ruby/object:Gem::Version
|
104
22
|
version: 0.5.0
|
@@ -106,23 +24,24 @@ dependencies:
|
|
106
24
|
prerelease: false
|
107
25
|
version_requirements: !ruby/object:Gem::Requirement
|
108
26
|
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0.5'
|
109
30
|
- - ">="
|
110
31
|
- !ruby/object:Gem::Version
|
111
32
|
version: 0.5.0
|
112
|
-
description:
|
33
|
+
description: This plug-in adds support for Salt to Foreman's Smart Proxy
|
113
34
|
email: foreman-dev@googlegroups.com
|
114
35
|
executables:
|
115
36
|
- foreman-node
|
116
|
-
- salt_python_wrapper
|
117
37
|
extensions: []
|
118
38
|
extra_rdoc_files:
|
119
|
-
- README.md
|
120
39
|
- LICENSE
|
40
|
+
- README.md
|
121
41
|
files:
|
122
42
|
- LICENSE
|
123
43
|
- README.md
|
124
44
|
- bin/foreman-node
|
125
|
-
- bin/salt_python_wrapper
|
126
45
|
- bundler.d/salt.rb
|
127
46
|
- etc/foreman.conf.example
|
128
47
|
- etc/foreman.yaml.example
|
@@ -150,9 +69,8 @@ files:
|
|
150
69
|
- settings.d/salt.yml.example
|
151
70
|
homepage: https://github.com/theforeman/smart_proxy_salt
|
152
71
|
licenses:
|
153
|
-
- GPL-3.0
|
72
|
+
- GPL-3.0-only
|
154
73
|
metadata: {}
|
155
|
-
post_install_message:
|
156
74
|
rdoc_options: []
|
157
75
|
require_paths:
|
158
76
|
- lib
|
@@ -160,16 +78,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
160
78
|
requirements:
|
161
79
|
- - ">="
|
162
80
|
- !ruby/object:Gem::Version
|
163
|
-
version: '
|
81
|
+
version: '2.7'
|
82
|
+
- - "<"
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '4'
|
164
85
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
165
86
|
requirements:
|
166
87
|
- - ">="
|
167
88
|
- !ruby/object:Gem::Version
|
168
89
|
version: '0'
|
169
90
|
requirements: []
|
170
|
-
|
171
|
-
rubygems_version: 2.7.6
|
172
|
-
signing_key:
|
91
|
+
rubygems_version: 3.6.7
|
173
92
|
specification_version: 4
|
174
93
|
summary: SaltStack Plug-In for Foreman's Smart Proxy
|
175
94
|
test_files: []
|
data/bin/salt_python_wrapper
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
#!/bin/sh
|
2
|
-
|
3
|
-
set -u
|
4
|
-
|
5
|
-
for py in 'python3' 'python'; do
|
6
|
-
exe=$(type -p ${py})
|
7
|
-
if [ -n "${exe}" ]; then
|
8
|
-
if ${exe} -c 'import salt.config'; then
|
9
|
-
${exe} "$@"
|
10
|
-
exit $?
|
11
|
-
fi
|
12
|
-
fi
|
13
|
-
done
|
14
|
-
|
15
|
-
echo "No usable python version found, check if python or python3 can import salt.config!" 1>&2
|
16
|
-
exit 1
|