Skip to content

Commit 6b4997c

Browse files
Enable the possibility to rfresh pillars on demand for a given host
1 parent 58b47b5 commit 6b4997c

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

lib/smart_proxy_salt/cli.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@ def highstate(host)
6969
shell_command(cmd)
7070
end
7171

72+
def refresh_pillar(host)
73+
find_salt_binaries
74+
cmd = [@sudo, '-u', Proxy::Salt::Plugin.settings.salt_command_user, @salt, '--async', escape_for_shell(host), 'saltutil.refresh_pillar']
75+
logger.info "Will run state.highstate for #{host}. Full command: #{cmd.join(' ')}"
76+
shell_command(cmd)
77+
end
78+
7279
def key_delete(host)
7380
find_salt_binaries
7481
cmd = [@sudo, '-u', Proxy::Salt::Plugin.settings.salt_command_user, @salt_key, '--yes', '-d', escape_for_shell(host)]

lib/smart_proxy_salt/salt_api.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,16 @@ class Api < ::Sinatra::Base
7070
end
7171
end
7272

73+
post '/pillar_refresh/:host' do
74+
content_type :json
75+
begin
76+
log_halt 500, "Failed salt run for #{params[:host]}: Check Log files" unless (result = Proxy::Salt.refresh_pillar(params[:host]))
77+
result
78+
rescue Exception => e
79+
log_halt 406, "Failed salt run for #{params[:host]}: #{e}"
80+
end
81+
end
82+
7383
delete '/key/:host' do
7484
content_type :json
7585
begin

0 commit comments

Comments
 (0)