def self.run(args = [])
super
return if @help_requested
check_for_start_lock
set_up_simp_environment
logfilepath = File.dirname(File.expand_path(@bootstrap_log))
FileUtils.mkpath(logfilepath) unless File.exists?(logfilepath)
@logfile = File.open(@bootstrap_log, 'w')
FileUtils.mkdir(@bootstrap_backup)
system('clear')
info('=== Starting SIMP Bootstrap ===', 'yellow.bold', '')
info("The log can be found at '#{@logfile.path}'\n")
ensure_puppet_agent_stopped
if @unsafe
warn('Any interrupts may cause system instability.', 'red.bold')
else
signals = ['INT','HUP','USR1','USR2']
signals.each do |sig|
Signal.trap(sig) { say "\nSafe mode enabled, ignoring interrupt".magenta }
end
info('Interrupts will be captured and ignored to ensure bootstrap integrity.', 'magenta.bold')
end
ensure_puppet_processes_stopped
handle_existing_puppet_certs
configure_bootstrap_puppetserver
agent_lockfile = "#{File.dirname(::Utils.puppet_info[:config]['agent_disabled_lockfile'])}/bootstrap.lock"
pupcmd = "puppet agent --onetime --no-daemonize --no-show_diff --verbose" +
" --no-splay --agent_disabled_lockfile=#{agent_lockfile}" +
" --masterport=8150 --ca_port=8150"
info('Running puppet agent, with --tags pupmod,simp', 'cyan')
linecounts = Array.new
linecounts << track_output("#{pupcmd} --tags pupmod,simp 2> /dev/null", '8150')
fix_file_contexts
info('Running puppet without tags', 'cyan')
pupcmd = "puppet agent --onetime --no-daemonize --no-show_diff --verbose --no-splay" +
" --agent_disabled_lockfile=#{agent_lockfile}"
(0..1).each do
track_output(pupcmd)
end
ensure_bootstrap_puppetserver_process_stopped
info('=== SIMP Bootstrap Finished! ===', 'yellow', '')
info("Duration of complete bootstrap: #{Time.now - @start_time} seconds")
if !system('ps -C httpd > /dev/null 2>&1') && (linecounts.include?(-1) || (linecounts.uniq.length < linecounts.length))
warn('Warning: Primitive checks indicate there may have been issues', 'magenta')
end
info("#{@logfile.path} contains details of the bootstrap actions performed.", 'yellow')
info('Prior to operation, you must reboot your system.', 'magenta.bold')
info('Run `puppet agent -t` after reboot to complete the bootstrap process.', 'magenta.bold')
info('It may take a few minutes before the puppetserver accepts agent', 'magenta.bold')
info('connections after boot.', 'magenta.bold')
execute('puppet agent --enable')
end