<s> import time <EOL> from fabric . api import env , run , sudo <EOL> from fabric . contrib . files import append , sed <EOL> from fabric . context_managers import settings as fabric_settings <EOL> from fabric . operations import reboot <EOL> import settings <EOL> DISTRO = "<STR_LIT>" <EOL> SALT_INSTALLERS = [ "<STR_LIT>" ] <EOL> def bootstrap ( ) : <EOL> """<STR_LIT>""" <EOL> run ( "<STR_LIT>" ) <EOL> with fabric_settings ( warn_only = True ) : <EOL> run ( "<STR_LIT>" ) <EOL> append ( "<STR_LIT>" , "<STR_LIT>" . format ( env . master_server . private_ip ) ) <EOL> with fabric_settings ( warn_only = True ) : <EOL> reboot ( ) <EOL> run ( "<STR_LIT>" ) <EOL> append ( "<STR_LIT>" , <EOL> "<STR_LIT>" ) <EOL> def upgrade ( ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError ( ) <EOL> def install_salt ( installer = "<STR_LIT>" ) : <EOL> """<STR_LIT>""" <EOL> if installer == "<STR_LIT>" : <EOL> append ( "<STR_LIT>" , <EOL> "<STR_LIT>" ) <EOL> run ( "<STR_LIT>" ) <EOL> run ( "<STR_LIT>" ) <EOL> run ( "<STR_LIT>" ) <EOL> else : <EOL> raise NotImplementedError ( ) <EOL> def setup_salt ( ) : <EOL> """<STR_LIT>""" <EOL> server = [ s for s in env . bootmachine_servers if s . public_ip == env . host ] [ <NUM_LIT:0> ] <EOL> if env . host == env . master_server . public_ip : <EOL> append ( "<STR_LIT>" , "<STR_LIT>" . format ( <EOL> settings . REMOTE_STATES_DIR ) ) <EOL> append ( "<STR_LIT>" , "<STR_LIT>" . format ( <EOL> settings . REMOTE_PILLARS_DIR ) ) <EOL> sed ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" . format ( env . master_server . private_ip ) ) <EOL> sed ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" . format ( server . name ) ) <EOL> append ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> for role in server . roles : <EOL> append ( "<STR_LIT>" , "<STR_LIT>" . format ( role ) ) <EOL> def start_salt ( ) : <EOL> """<STR_LIT>""" <EOL> with fabric_settings ( warn_only = True ) : <EOL> if env . host == env . master_server . public_ip : <EOL> sudo ( "<STR_LIT>" ) <EOL> time . sleep ( <NUM_LIT:3> ) <EOL> sudo ( "<STR_LIT>" ) <EOL> def stop_salt ( ) : <EOL> """<STR_LIT>""" <EOL> with fabric_settings ( warn_only = True ) : <EOL> if env . host == env . master_server . public_ip : <EOL> sudo ( "<STR_LIT>" ) <EOL> sudo ( "<STR_LIT>" ) <EOL> def restart_salt ( ) : <EOL> """<STR_LIT>""" <EOL> stop_salt ( ) <EOL> start_salt ( ) </s>
