def enabled(name='allprofiles'):
 ret = {'name': name, 'result': True, 'changes': {}, 'comment': ''}
 action = False
 check_name = None
 if (name != 'allprofiles'):
  check_name = True
 current_config = __salt__['firewall.get_config']()
 if (check_name and (name not in current_config)):
  ret['result'] = False
  ret['comment'] = 'Profile {0} does not exist in firewall.get_config'.format(name)
  return ret
 for key in current_config:
  if (not current_config[key]):
   if (check_name and (key != name)):
    continue
   action = True
   ret['changes'] = {'fw': 'enabled'}
   break
 if __opts__['test']:
  ret['result'] = ((not action) or None)
  return ret
 if action:
  ret['result'] = __salt__['firewall.enable'](name)
  if (not ret['result']):
   if check_name:
    msg = 'Firewall profile {0} could not be enabled'.format(name)
   else:
    msg = 'Could not enable the FW'
   ret['comment'] = msg
 else:
  if check_name:
   msg = 'Firewall profile {0} is enabled'.format(name)
  else:
   msg = 'All the firewall profiles are enabled'
  ret['comment'] = msg
 return ret

def enabled ( name = 'allprofiles' ) : ret = { 'name' : name , 'result' : True , 'changes' : { } , 'comment' : '' } action = False check_name = None if ( name != 'allprofiles' ) : check_name = True current_config = __salt__ [ 'firewall.get_config' ] ( ) if ( check_name and ( name not in current_config ) ) : ret [ 'result' ] = False ret [ 'comment' ] = 'Profile {0} does not exist in firewall.get_config' . format ( name ) return ret for key in current_config : if ( not current_config [ key ] ) : if ( check_name and ( key != name ) ) : continue action = True ret [ 'changes' ] = { 'fw' : 'enabled' } break if __opts__ [ 'test' ] : ret [ 'result' ] = ( ( not action ) or None ) return ret if action : ret [ 'result' ] = __salt__ [ 'firewall.enable' ] ( name ) if ( not ret [ 'result' ] ) : if check_name : msg = 'Firewall profile {0} could not be enabled' . format ( name ) else : msg = 'Could not enable the FW' ret [ 'comment' ] = msg else : if check_name : msg = 'Firewall profile {0} is enabled' . format ( name ) else : msg = 'All the firewall profiles are enabled' ret [ 'comment' ] = msg return ret
ensure that the service is enabled on boot .