Skip to content

Commit

Permalink
update puppetrun setting default to true on foreman server using fore…
Browse files Browse the repository at this point in the history
…man api
  • Loading branch information
cwolferh committed May 1, 2013
1 parent 8f8c302 commit 193bfb3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
4 changes: 4 additions & 0 deletions foreman-params.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
"user": "admin",
"passwd": "changeme"
},
"settings": [{
"name": "puppetrun",
"value": "true"
}],
"proxy": {
"name": "proxy1",
"host": "https://foreman_hostname:8443"
Expand Down
20 changes: 20 additions & 0 deletions foreman-setup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,24 @@ def create_puppetos(puppetos)
end
end

def update(cmd, data)
response = @client[cmd].put(data)
rescue RestClient::UnprocessableEntity => e
@log.warn("PUT KO: #{data} => #{e.response}")
else
@log.info("PUT OK: #{data}")
end

def update_settings(settings)
settings.each do|s|
results = @client['settings'].get(:params => { :search => s['name'] })
server_setting = JSON.load(results)[0]
puts server_setting
update( 'settings/'+server_setting['setting']['id'].to_s(), :setting => {
:value => s['value'] })
end
end

def usage
puts "Usage: #{File.basename($0)} proxy | globals | hostgroups"
puts " Multiple commands can be used at same time"
Expand Down Expand Up @@ -139,6 +157,8 @@ def init
create_globals(@params['globals'])
when 'hostgroups'
create_hostgroups(@params['hostgroups'])
when 'settings'
update_settings(@params['settings'])
else
usage
end
Expand Down
1 change: 1 addition & 0 deletions foreman_server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ popd

ruby foreman-setup.rb globals
ruby foreman-setup.rb hostgroups
ruby foreman-setup.rb settings

# write client-register-to-foreman script
# TODO don't hit yum unless packages are not installed
Expand Down

0 comments on commit 193bfb3

Please sign in to comment.