'run the idempotent ansible code'

@staticmethod
def run_ansible(params, check_mode):

    ocenv = OCEnv(params['namespace'], params['kind'], params['env_vars'], resource_name=params['name'], kubeconfig=params['kubeconfig'], verbose=params['debug'])
    state = params['state']
    api_rval = ocenv.get()
    if (state == 'list'):
        return {'changed': False, 'results': api_rval['results'], 'state': 'list'}
    if (state == 'absent'):
        for key in params.get('env_vars', {}).keys():
            if ocenv.resource.exists_env_key(key):
                if check_mode:
                    return {'changed': False, 'msg': 'CHECK_MODE:    Would    have    performed    a    delete.'}
                api_rval = ocenv.delete()
                return {'changed': True, 'state': 'absent'}
        return {'changed': False, 'state': 'absent'}
    if (state == 'present'):
        for (key, value) in params.get('env_vars', {}).items():
            if (not ocenv.key_value_exists(key, value)):
                if check_mode:
                    return {'changed': False, 'msg': 'CHECK_MODE:    Would    have    performed    a    create.'}
                api_rval = ocenv.put()
                if (api_rval['returncode'] != 0):
                    return {'failed': True, 'msg': api_rval}
                api_rval = ocenv.get()
                if (api_rval['returncode'] != 0):
                    return {'failed': True, 'msg': api_rval}
                return {'changed': True, 'results': api_rval['results'], 'state': 'present'}
        return {'changed': False, 'results': api_rval['results'], 'state': 'present'}
    return {'failed': True, 'changed': False, 'msg': ('Unknown    state    passed.    %s' % state)}
