'run the ansible idempotent code'

@staticmethod
def run_ansible(params, check_mode):

    ocprocess = OCProcess(params['namespace'], params['template_name'], params['params'], params['create'], kubeconfig=params['kubeconfig'], tdata=params['content'], verbose=params['debug'])
    state = params['state']
    api_rval = ocprocess.get()
    if (state == 'list'):
        if (api_rval['returncode'] != 0):
            return {'failed': True, 'msg': api_rval}
        return {'changed': False, 'results': api_rval, 'state': state}
    elif (state == 'present'):
        if (check_mode and params['create']):
            return {'changed': True, 'msg': 'CHECK_MODE:    Would    have    processed    template.'}
        if ((not ocprocess.exists()) or (not params['reconcile'])):
            api_rval = ocprocess.process()
            if (api_rval['returncode'] != 0):
                return {'failed': True, 'msg': api_rval}
            if params['create']:
                return {'changed': True, 'results': api_rval, 'state': state}
            return {'changed': False, 'results': api_rval, 'state': state}
    update = False
    rval = []
    all_results = ocprocess.needs_update()
    for (obj, status) in all_results:
        if status:
            ocprocess.delete(obj)
            results = ocprocess.create_obj(obj)
            results['kind'] = obj['kind']
            rval.append(results)
            update = True
    if (not update):
        return {'changed': update, 'results': api_rval, 'state': state}
    for cmd in rval:
        if (cmd['returncode'] != 0):
            return {'failed': True, 'changed': update, 'msg': rval, 'state': state}
    return {'changed': update, 'results': rval, 'state': state}
