def env_present(name, value=None, user='root'):
 ret = {'changes': {}, 'comment': '', 'name': name, 'result': True}
 if __opts__['test']:
  status = _check_cron_env(user, name, value=value)
  ret['result'] = None
  if (status == 'absent'):
   ret['comment'] = 'Cron env {0} is set to be added'.format(name)
  elif (status == 'present'):
   ret['result'] = True
   ret['comment'] = 'Cron env {0} already present'.format(name)
  elif (status == 'update'):
   ret['comment'] = 'Cron env {0} is set to be updated'.format(name)
  return ret
 data = __salt__['cron.set_env'](user, name, value=value)
 if (data == 'present'):
  ret['comment'] = 'Cron env {0} already present'.format(name)
  return ret
 if (data == 'new'):
  ret['comment'] = "Cron env {0} added to {1}'s crontab".format(name, user)
  ret['changes'] = {user: name}
  return ret
 if (data == 'updated'):
  ret['comment'] = 'Cron env {0} updated'.format(name)
  ret['changes'] = {user: name}
  return ret
 ret['comment'] = 'Cron env {0} for user {1} failed to commit with error \n{2}'.format(name, user, data)
 ret['result'] = False
 return ret

def env_present ( name , value = None , user = 'root' ) : ret = { 'changes' : { } , 'comment' : '' , 'name' : name , 'result' : True } if __opts__ [ 'test' ] : status = _check_cron_env ( user , name , value = value ) ret [ 'result' ] = None if ( status == 'absent' ) : ret [ 'comment' ] = 'Cron env {0} is set to be added' . format ( name ) elif ( status == 'present' ) : ret [ 'result' ] = True ret [ 'comment' ] = 'Cron env {0} already present' . format ( name ) elif ( status == 'update' ) : ret [ 'comment' ] = 'Cron env {0} is set to be updated' . format ( name ) return ret data = __salt__ [ 'cron.set_env' ] ( user , name , value = value ) if ( data == 'present' ) : ret [ 'comment' ] = 'Cron env {0} already present' . format ( name ) return ret if ( data == 'new' ) : ret [ 'comment' ] = "Cron env {0} added to {1}'s crontab" . format ( name , user ) ret [ 'changes' ] = { user : name } return ret if ( data == 'updated' ) : ret [ 'comment' ] = 'Cron env {0} updated' . format ( name ) ret [ 'changes' ] = { user : name } return ret ret [ 'comment' ] = 'Cron env {0} for user {1} failed to commit with error \n{2}' . format ( name , user , data ) ret [ 'result' ] = False return ret
verifies that the specified environment variable is present in the crontab for the specified user .