smart_proxy_salt 1.0.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 716d33f19133ef06e16cf558c8a43f44d3bbd4db
4
- data.tar.gz: 27104bd5181a5dd086c0ac5f76932e5a6ca59a99
3
+ metadata.gz: 77c8f6c3ad50715f41fb5606a65ddd3cb6f06bd1
4
+ data.tar.gz: 61153e01b2c2043c19b22f33a651932c6c8fb8b9
5
5
  SHA512:
6
- metadata.gz: 4137417072ef95e3cf394ab307c04c221e02a973b169ceeecdcaeef8980a3e610bf19825b361275ad8426023554333cc05075da5de91df36782f0a9e5c4e6d39
7
- data.tar.gz: 47a173fe70cb02e92a169a1b3fe7cff2160a3987586db6d9e4fe9a5a8fc20d525733de325a7f29aa9fba7d95b1308315ba0cf388b6a1769cb9192108da18dfe7
6
+ metadata.gz: de0c1674f1e3742a185e3f1f4bb9574e8c2c498cc3fa1278914c1e0617517cfe19a63774f4c53d3b567650bbc959816ee312a7a7e6dee3cd42785d071de1c13f
7
+ data.tar.gz: f85fb6810cbb2c47846f167875880825b788f9cf7cd430358c1d58becdaae63b4b2b9f8884428104a5626288d15e761d415019a2bb24b2f0acedbffca49a5fb6
@@ -5,7 +5,7 @@
5
5
 
6
6
  require 'yaml'
7
7
 
8
- $settings_file = "/etc/salt/foreman.yaml"
8
+ $settings_file = '/etc/salt/foreman.yaml'
9
9
  SETTINGS = YAML.load_file($settings_file)
10
10
 
11
11
  require 'net/http'
@@ -22,7 +22,7 @@ rescue LoadError
22
22
  require 'rubygems' rescue nil
23
23
  require 'json'
24
24
  rescue LoadError => e
25
- puts "You need the `json` gem to use the Foreman ENC script"
25
+ puts 'You need the `json` gem to use the Foreman ENC script'
26
26
  # code 1 is already used below
27
27
  exit 2
28
28
  end
@@ -32,7 +32,7 @@ def foreman_url
32
32
  "#{SETTINGS[:proto]}://#{SETTINGS[:host]}:#{SETTINGS[:port]}"
33
33
  end
34
34
 
35
- def valid_hostname? hostname
35
+ def valid_hostname?(hostname)
36
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/
37
37
  end
38
38
 
@@ -53,7 +53,7 @@ def get_grains(minion)
53
53
  end
54
54
  end
55
55
 
56
- def plain_grains minion
56
+ def plain_grains(minion)
57
57
  # We have to get the grains from the cache, because the client
58
58
  # is probably running 'state.highstate' right now.
59
59
  #
@@ -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', mode='r+') do |python|
88
88
  python.write script
89
89
  python.close_write
90
90
  result = python.read
@@ -169,15 +169,15 @@ def enc(minion)
169
169
 
170
170
  res = http.start { |http| http.request(req) }
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"
172
+ raise "Error retrieving node #{minion}: #{res.class}\nCheck Foreman's /var/log/foreman/production.log for more information." unless res.code == '200'
173
173
  res.body
174
174
  end
175
175
 
176
- minion = ARGV[0] || raise("Must provide minion as an argument")
176
+ minion = ARGV[0] || raise('Must provide minion as an argument')
177
177
 
178
- raise "Invalid hostname" unless valid_hostname? minion
178
+ raise 'Invalid hostname' unless valid_hostname? minion
179
179
  begin
180
- result = ""
180
+ result = ''
181
181
 
182
182
  if SETTINGS[:upload_grains]
183
183
  timeout(SETTINGS[:timeout]) do
@@ -6,8 +6,9 @@ module Proxy::Salt
6
6
  class Api < ::Sinatra::Base
7
7
  include ::Proxy::Log
8
8
  helpers ::Proxy::Helpers
9
+ authorize_with_ssl_client
9
10
 
10
- post "/autosign/:host" do
11
+ post '/autosign/:host' do
11
12
  content_type :json
12
13
  begin
13
14
  Proxy::Salt.autosign_create(params[:host]).to_json
@@ -16,7 +17,7 @@ module Proxy::Salt
16
17
  end
17
18
  end
18
19
 
19
- delete "/autosign/:host" do
20
+ delete '/autosign/:host' do
20
21
  content_type :json
21
22
  begin
22
23
  Proxy::Salt.autosign_remove(params[:host]).to_json
@@ -27,7 +28,7 @@ module Proxy::Salt
27
28
  end
28
29
  end
29
30
 
30
- get "/autosign" do
31
+ get '/autosign' do
31
32
  content_type :json
32
33
  begin
33
34
  Proxy::Salt::autosign_list.to_json
@@ -36,17 +37,17 @@ module Proxy::Salt
36
37
  end
37
38
  end
38
39
 
39
- post "/highstate/:host" do
40
+ post '/highstate/:host' do
40
41
  content_type :json
41
42
  begin
42
- log_halt 500, "Failed salt run for #{params[:host]}: Check Log files" unless result=Proxy::Salt.highstate(params[:host])
43
+ log_halt 500, "Failed salt run for #{params[:host]}: Check Log files" unless (result = Proxy::Salt.highstate(params[:host]))
43
44
  result
44
45
  rescue => e
45
46
  log_halt 406, "Failed salt run for #{params[:host]}: #{e}"
46
47
  end
47
48
  end
48
49
 
49
- delete "/key/:host" do
50
+ delete '/key/:host' do
50
51
  content_type :json
51
52
  begin
52
53
  Proxy::Salt.key_delete(params[:host])
@@ -55,7 +56,7 @@ module Proxy::Salt
55
56
  end
56
57
  end
57
58
 
58
- post "/key/:host" do
59
+ post '/key/:host' do
59
60
  content_type :json
60
61
  begin
61
62
  Proxy::Salt::key_accept(params[:host])
@@ -64,7 +65,7 @@ module Proxy::Salt
64
65
  end
65
66
  end
66
67
 
67
- delete "/key/reject/:host" do
68
+ delete '/key/reject/:host' do
68
69
  content_type :json
69
70
  begin
70
71
  Proxy::Salt::key_reject(params[:host])
@@ -73,7 +74,7 @@ module Proxy::Salt
73
74
  end
74
75
  end
75
76
 
76
- get "/key" do
77
+ get '/key' do
77
78
  content_type :json
78
79
  begin
79
80
  Proxy::Salt::key_list.to_json
@@ -1,4 +1,4 @@
1
1
  require 'smart_proxy_salt/salt_api'
2
- map "/salt" do
2
+ map '/salt' do
3
3
  run Proxy::Salt::Api
4
4
  end
@@ -33,14 +33,14 @@ module Proxy::Salt
33
33
  Proxy::Salt::Plugin.settings.autosign_file
34
34
  end
35
35
 
36
- def autosign_create host
36
+ def autosign_create(host)
37
37
  FileUtils.touch(autosign_file) unless File.exist?(autosign_file)
38
38
 
39
39
  autosign = open(autosign_file, File::RDWR)
40
40
 
41
41
  found = false
42
42
  autosign.each_line { |line| found = true if line.chomp == host }
43
- autosign.puts host if found == false
43
+ autosign.puts host unless found
44
44
  autosign.close
45
45
 
46
46
  result = {:message => "Added #{host} to autosign"}
@@ -48,7 +48,7 @@ module Proxy::Salt
48
48
  result
49
49
  end
50
50
 
51
- def autosign_remove host
51
+ def autosign_remove(host)
52
52
  raise "No such file #{autosign_file}" unless File.exists?(autosign_file)
53
53
 
54
54
  found = false
@@ -83,26 +83,26 @@ module Proxy::Salt
83
83
  }
84
84
  end
85
85
 
86
- def highstate host
86
+ def highstate(host)
87
87
  find_salt_binaries
88
- cmd = [@sudo, '-u', Proxy::Salt::Plugin.settings.salt_command_user, @salt, "--async", escape_for_shell(host), "state.highstate"]
89
- logger.info "Will run state.highstate for #{host}. Full command: #{cmd.join(" ")}"
88
+ cmd = [@sudo, '-u', Proxy::Salt::Plugin.settings.salt_command_user, @salt, '--async', escape_for_shell(host), 'state.highstate']
89
+ logger.info "Will run state.highstate for #{host}. Full command: #{cmd.join(' ')}"
90
90
  shell_command(cmd)
91
91
  end
92
92
 
93
- def key_delete host
93
+ def key_delete(host)
94
94
  find_salt_binaries
95
95
  cmd = [@sudo, '-u', Proxy::Salt::Plugin.settings.salt_command_user, @salt_key, '--yes', '-d', escape_for_shell(host)]
96
96
  shell_command(cmd)
97
97
  end
98
98
 
99
- def key_reject host
99
+ def key_reject(host)
100
100
  find_salt_binaries
101
101
  cmd = [@sudo, '-u', Proxy::Salt::Plugin.settings.salt_command_user, @salt_key, '--yes', '-r', escape_for_shell(host)]
102
102
  shell_command(cmd)
103
103
  end
104
104
 
105
- def key_accept host
105
+ def key_accept(host)
106
106
  find_salt_binaries
107
107
  cmd = [@sudo, '-u', Proxy::Salt::Plugin.settings.salt_command_user, @salt_key, '--yes', '-a', escape_for_shell(host)]
108
108
  shell_command(cmd)
@@ -116,7 +116,7 @@ module Proxy::Salt
116
116
  response = `#{command}`
117
117
  unless $? == 0
118
118
  logger.warn "Failed to run salt-key: #{response}"
119
- raise "Execution of salt-key failed, check log files"
119
+ raise 'Execution of salt-key failed, check log files'
120
120
  end
121
121
 
122
122
  keys_hash = {}
@@ -1,5 +1,5 @@
1
1
  module Proxy
2
2
  module Salt
3
- VERSION = '1.0.0'
3
+ VERSION = '2.0.0'
4
4
  end
5
5
  end
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: 1.0.0
4
+ version: 2.0.0
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: 2014-11-19 00:00:00.000000000 Z
12
+ date: 2015-03-02 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
@@ -20,20 +20,20 @@ extra_rdoc_files:
20
20
  - README.md
21
21
  - LICENSE
22
22
  files:
23
+ - LICENSE
24
+ - README.md
23
25
  - bin/foreman-node
26
+ - bundler.d/salt.rb
24
27
  - cron/smart_proxy_salt
25
28
  - etc/foreman.yaml.example
26
- - lib/smart_proxy_salt/salt_main.rb
27
- - lib/smart_proxy_salt/salt_http_config.ru
29
+ - lib/smart_proxy_salt.rb
28
30
  - lib/smart_proxy_salt/salt.rb
29
31
  - lib/smart_proxy_salt/salt_api.rb
32
+ - lib/smart_proxy_salt/salt_http_config.ru
33
+ - lib/smart_proxy_salt/salt_main.rb
30
34
  - lib/smart_proxy_salt/version.rb
31
- - lib/smart_proxy_salt.rb
32
35
  - sbin/upload-salt-reports
33
36
  - settings.d/salt.yml.example
34
- - bundler.d/salt.rb
35
- - README.md
36
- - LICENSE
37
37
  homepage: https://github.com/theforeman/smart_proxy_salt
38
38
  licenses:
39
39
  - GPLv3
@@ -44,17 +44,17 @@ require_paths:
44
44
  - lib
45
45
  required_ruby_version: !ruby/object:Gem::Requirement
46
46
  requirements:
47
- - - '>='
47
+ - - ">="
48
48
  - !ruby/object:Gem::Version
49
49
  version: '0'
50
50
  required_rubygems_version: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  requirements: []
56
56
  rubyforge_project:
57
- rubygems_version: 2.1.11
57
+ rubygems_version: 2.2.2
58
58
  signing_key:
59
59
  specification_version: 4
60
60
  summary: SaltStack Plug-In for Foreman's Smart Proxy