<s> '''<STR_LIT>''' <EOL> from provy . core import Role <EOL> from provy . more . debian . package . aptitude import AptitudeRole <EOL> class NginxRole ( Role ) : <EOL> '''<STR_LIT>''' <EOL> def __available_site_for ( self , name ) : <EOL> return '<STR_LIT>' % name <EOL> def __enabled_site_for ( self , name ) : <EOL> return '<STR_LIT>' % name <EOL> def provision ( self ) : <EOL> '''<STR_LIT>''' <EOL> with self . using ( AptitudeRole ) as role : <EOL> role . ensure_up_to_date ( ) <EOL> role . ensure_package_installed ( '<STR_LIT>' ) <EOL> def cleanup ( self ) : <EOL> '''<STR_LIT>''' <EOL> super ( NginxRole , self ) . cleanup ( ) <EOL> if '<STR_LIT>' in self . context and self . context [ '<STR_LIT>' ] : <EOL> self . restart ( ) <EOL> def ensure_conf ( self , conf_template , options = { } , nginx_conf_path = '<STR_LIT>' ) : <EOL> '''<STR_LIT>''' <EOL> result = self . update_file ( conf_template , <EOL> nginx_conf_path , <EOL> options = options , <EOL> sudo = True ) <EOL> if result : <EOL> self . log ( '<STR_LIT>' ) <EOL> self . ensure_restart ( ) <EOL> def ensure_site_disabled ( self , site ) : <EOL> '''<STR_LIT>''' <EOL> result = self . remove_file ( self . __enabled_site_for ( site ) , sudo = True ) <EOL> if result : <EOL> self . log ( '<STR_LIT>' % site ) <EOL> self . ensure_restart ( ) <EOL> def ensure_site_enabled ( self , site ) : <EOL> '''<STR_LIT>''' <EOL> result = self . remote_symlink ( self . __available_site_for ( site ) , <EOL> self . __enabled_site_for ( site ) , <EOL> sudo = True ) <EOL> if result : <EOL> self . log ( '<STR_LIT>' % site ) <EOL> self . ensure_restart ( ) <EOL> def create_site ( self , site , template , options = { } ) : <EOL> '''<STR_LIT>''' <EOL> result = self . update_file ( template , <EOL> self . __available_site_for ( site ) , <EOL> options = options , sudo = True ) <EOL> if result : <EOL> self . log ( '<STR_LIT>' % site ) <EOL> self . ensure_restart ( ) <EOL> def ensure_restart ( self ) : <EOL> '''<STR_LIT>''' <EOL> self . context [ '<STR_LIT>' ] = True <EOL> def restart ( self ) : <EOL> '''<STR_LIT>''' <EOL> command = '<STR_LIT>' <EOL> self . execute ( command , sudo = True ) </s>
