def self.ensure_bootstrap_puppetserver_process_stopped
begin
pserver_proc = %x{netstat -tlpn}.split("\n").select{|x| x =~ /\d:8150/}
unless pserver_proc.empty?
pserver_port = %x{puppet config print masterport}
unless (pserver_port == '8150')
pserver_pid = pserver_proc.first.split.last.split('/').first.to_i
Process.kill('KILL',pserver_pid)
end
end
rescue Exception => e
warn(e.message)
warn("The bootstrap puppetserver process running on port 8150 could not be killed." +
"\n Please check your configuration!", 'magenta')
end
end