Merge "Do restart mcollective after provisioning"

This commit is contained in:
Jenkins 2016-05-10 18:12:31 +00:00 committed by Gerrit Code Review
commit ea7350a649
1 changed files with 8 additions and 1 deletions

9
agent
View File

@ -32,6 +32,7 @@ require 'uri'
# TODO(vsharshov): replace below lines by this string after excluding Ruby 1.8 # TODO(vsharshov): replace below lines by this string after excluding Ruby 1.8
require 'pathname' require 'pathname'
require 'rexml/document' require 'rexml/document'
require 'socket'
include REXML include REXML
unless Process.euid == 0 unless Process.euid == 0
@ -1057,6 +1058,10 @@ def write_data_to_file(logger, filename, data)
end end
end end
def provisioned?
Socket.gethostname != 'bootstrap'
end
logger = Logger.new(STDOUT) logger = Logger.new(STDOUT)
if File.exist?('/etc/nailgun_uid') if File.exist?('/etc/nailgun_uid')
@ -1100,7 +1105,9 @@ begin
end end
new_id = JSON.parse(resp.body)['id'] new_id = JSON.parse(resp.body)['id']
mc_config = McollectiveConfig.new(logger) mc_config = McollectiveConfig.new(logger)
mc_config.replace_identity(new_id) unless provisioned?
mc_config.replace_identity(new_id)
end
write_data_to_file(logger, '/etc/nailgun_uid', new_id.to_s) write_data_to_file(logger, '/etc/nailgun_uid', new_id.to_s)
rescue => ex rescue => ex
# NOTE(mihgen): There is no need to retry - cron will do it for us # NOTE(mihgen): There is no need to retry - cron will do it for us