smart_proxy_salt 2.1.6 → 2.1.7

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
  SHA1:
3
- metadata.gz: c7dc004f36b7961d8101ee986cfa040e698ea4d7
4
- data.tar.gz: 1a72efead0f951b1bb8f15d496a4951a280ca093
3
+ metadata.gz: 6a479ace7ffeb895281d60a176b7f47c5ed96975
4
+ data.tar.gz: af15fc5c2a9072e3e7a70dc57b520895b2f94276
5
5
  SHA512:
6
- metadata.gz: 51057ad26a27607f5cb9fd79f7b492d1583706e6a67f1210701e3775adecc6487728ae9cc6a579626ef16e2a626813a33a86930ff825893eea8bfae7f7e7e80f
7
- data.tar.gz: 9a1468d8a95ea045cebeb772947e8e349fd8ae6772e08f3fd4acf3d495cdd5775c5f2756078d44694511c19c9a207d0d0efd5cae394409d3a76c3c99fe482fa2
6
+ metadata.gz: 5c84eaea9f1a759457655941dd8a5c053543968bea016fe5e8301629d852c947a69ede9b8f331c6f4871c7fcc7484317d2efe5613323b3cbe0ba22c4351038b7
7
+ data.tar.gz: 8a77baac462e5697879b14fbcec1a96d9b93a7cdca86f527aafb84edf47519bdf2b7b5c72a60322538d7b32c3e638e0af19d66b071885c491d3778c7ea98b113
data/bin/foreman-node CHANGED
@@ -33,7 +33,7 @@ def foreman_url
33
33
  end
34
34
 
35
35
  def valid_hostname?(hostname)
36
- hostname =~ /\A(([a-z0-9]|[a-z0-9][a-z0-9\-]*[a-z0-9])\.)*([a-z0-9]|[a-z0-9][a-z0-9\-]*[a-z0-9])\z/
36
+ hostname =~ /\A(([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])\z/
37
37
  end
38
38
 
39
39
  def get_grains(minion)
@@ -84,7 +84,7 @@ if __name__ == '__main__':
84
84
  print json.dumps(ret)
85
85
  EOF
86
86
 
87
- result = IO.popen('python', mode='r+') do |python|
87
+ result = IO.popen('python 2>/dev/null', mode='r+') do |python|
88
88
  python.write script
89
89
  python.close_write
90
90
  result = python.read
@@ -146,6 +146,8 @@ def upload_grains(minion)
146
146
  res.cert = OpenSSL::X509::Certificate.new(File.read(SETTINGS[:ssl_cert]))
147
147
  res.key = OpenSSL::PKey::RSA.new(File.read(SETTINGS[:ssl_key]), nil)
148
148
  end
149
+ elsif SETTINGS[:username] && SETTINGS[:password]
150
+ req.basic_auth(SETTINGS[:username], SETTINGS[:password])
149
151
  end
150
152
  res.start { |http| http.request(req) }
151
153
  rescue => e
@@ -170,6 +172,8 @@ def enc(minion)
170
172
  http.cert = OpenSSL::X509::Certificate.new(File.read(SETTINGS[:ssl_cert]))
171
173
  http.key = OpenSSL::PKey::RSA.new(File.read(SETTINGS[:ssl_key]), nil)
172
174
  end
175
+ elsif SETTINGS[:username] && SETTING[:password]
176
+ req.basic_auth(SETTINGS[:username], SETTINGS[:password])
173
177
  end
174
178
 
175
179
  res = http.start { |http| http.request(req) }
@@ -185,12 +189,12 @@ begin
185
189
  result = ''
186
190
 
187
191
  if SETTINGS[:upload_grains]
188
- timeout(SETTINGS[:timeout]) do
192
+ Timeout.timeout(SETTINGS[:timeout]) do
189
193
  upload_grains(minion)
190
194
  end
191
195
  end
192
196
 
193
- timeout(SETTINGS[:timeout]) do
197
+ Timeout.timeout(SETTINGS[:timeout]) do
194
198
  result = enc(minion)
195
199
  end
196
200
  puts result
@@ -2,9 +2,13 @@
2
2
  :proto: https
3
3
  :host: foreman.example.com
4
4
  :port: 443
5
+ # if using http with ssl certificates
5
6
  :ssl_ca: "/var/lib/puppet/ssl/certs/ca.pem"
6
7
  :ssl_cert: "/var/lib/puppet/ssl/private_keys/foreman.example.com.pem"
7
8
  :ssl_key: "/var/lib/puppet/ssl/certs/foreman.example.com.pem"
9
+ # if using http with username and password instead of https with certicates
10
+ #:username: admin
11
+ #:password: changeme
8
12
  :timeout: 10
9
13
  :salt: /usr/bin/salt
10
14
  :upload_grains: true
@@ -1,5 +1,5 @@
1
1
  module Proxy
2
2
  module Salt
3
- VERSION = '2.1.6'
3
+ VERSION = '2.1.7'
4
4
  end
5
5
  end
@@ -7,10 +7,12 @@ LOCK_FILE = '/var/lock/salt-report-upload.lock'
7
7
 
8
8
  import urllib
9
9
  import httplib
10
+ import ssl
10
11
  import json
11
12
  import yaml
12
13
  import os
13
14
  import sys
15
+ import base64
14
16
 
15
17
  import traceback
16
18
 
@@ -95,12 +97,19 @@ def upload(jobs):
95
97
  'Content-Type': 'application/json'}
96
98
 
97
99
  if config[':proto'] == 'https':
100
+ ctx = ssl.create_default_context()
101
+ ctx.load_cert_chain(certfile=config[':ssl_cert'], keyfile=config[':ssl_key'])
102
+ if config[':ssl_ca']:
103
+ ctx.load_verify_locations(cafile=config[':ssl_ca'])
98
104
  connection = httplib.HTTPSConnection(config[':host'],
99
- port=config[':port'], key_file=config[':ssl_key'],
100
- cert_file=config[':ssl_cert'])
105
+ port=config[':port'], context=ctx)
101
106
  else:
102
107
  connection = httplib.HTTPConnection(config[':host'],
103
108
  port=config[':port'])
109
+ if ':username' in config and ':password' in config:
110
+ token = base64.b64encode('{}:{}'.format(config[':username'],
111
+ config[':password']))
112
+ headers['Authorization'] = 'Basic {}'.format(token)
104
113
 
105
114
  for id in jobs[0]:
106
115
  job = jobs[1][id]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smart_proxy_salt
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.6
4
+ version: 2.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Moll
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-10-25 00:00:00.000000000 Z
12
+ date: 2016-10-07 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: SaltStack Plug-In for Foreman's Smart Proxy
15
15
  email: foreman-dev@googlegroups.com
@@ -56,7 +56,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
56
56
  version: '0'
57
57
  requirements: []
58
58
  rubyforge_project:
59
- rubygems_version: 2.4.5
59
+ rubygems_version: 2.5.1
60
60
  signing_key:
61
61
  specification_version: 4
62
62
  summary: SaltStack Plug-In for Foreman's Smart Proxy