'run the ansible idempotent code'

@staticmethod
def run_ansible(params, check_mode):

    oc_cm = OCConfigMap(params['name'], params['from_file'], params['from_literal'], params['state'], params['namespace'], kubeconfig=params['kubeconfig'], verbose=params['debug'])
    state = params['state']
    api_rval = oc_cm.get()
    if ('failed' in api_rval):
        return {'failed': True, 'msg': api_rval}
    if (state == 'list'):
        return {'changed': False, 'results': api_rval, 'state': state}
    if (not params['name']):
        return {'failed': True, 'msg': 'Please    specify    a    name    when    state    is    absent|present.'}
    if (state == 'absent'):
        if (not Utils.exists(api_rval['results'], params['name'])):
            return {'changed': False, 'state': 'absent'}
        if check_mode:
            return {'changed': True, 'msg': 'CHECK_MODE:    Would    have    performed    a    delete.'}
        api_rval = oc_cm.delete()
        if (api_rval['returncode'] != 0):
            return {'failed': True, 'msg': api_rval}
        return {'changed': True, 'results': api_rval, 'state': state}
    if (state == 'present'):
        if (not Utils.exists(api_rval['results'], params['name'])):
            if check_mode:
                return {'changed': True, 'msg': 'Would    have    performed    a    create.'}
            api_rval = oc_cm.create()
            if (api_rval['returncode'] != 0):
                return {'failed': True, 'msg': api_rval}
            api_rval = oc_cm.get()
            if (api_rval['returncode'] != 0):
                return {'failed': True, 'msg': api_rval}
            return {'changed': True, 'results': api_rval, 'state': state}
        if oc_cm.needs_update():
            api_rval = oc_cm.update()
            if (api_rval['returncode'] != 0):
                return {'failed': True, 'msg': api_rval}
            api_rval = oc_cm.get()
            if (api_rval['returncode'] != 0):
                return {'failed': True, 'msg': api_rval}
            return {'changed': True, 'results': api_rval, 'state': state}
        return {'changed': False, 'results': api_rval, 'state': state}
    return {'failed': True, 'msg': 'Unknown    state    passed.    {}'.format(state)}
