'Run the idempotent ansible code'

@staticmethod
def run_ansible(params, check_mode):

    oc_svc = OCService(params['name'], params['namespace'], params['labels'], params['selector'], params['clusterip'], params['portalip'], params['ports'], params['session_affinity'], params['service_type'], params['external_ips'], params['kubeconfig'], params['debug'])
    state = params['state']
    api_rval = oc_svc.get()
    if (api_rval['returncode'] != 0):
        return {'failed': True, 'msg': api_rval}
    if (state == 'list'):
        return {'changed': False, 'results': api_rval, 'state': state}
    if (state == 'absent'):
        if oc_svc.exists():
            if check_mode:
                return {'changed': True, 'msg': 'CHECK_MODE:    Would    have    performed    a    delete.'}
            api_rval = oc_svc.delete()
            return {'changed': True, 'results': api_rval, 'state': state}
        return {'changed': False, 'state': state}
    if (state == 'present'):
        if (not oc_svc.exists()):
            if check_mode:
                return {'changed': True, 'msg': 'CHECK_MODE:    Would    have    performed    a    create.'}
            api_rval = oc_svc.create()
            if (api_rval['returncode'] != 0):
                return {'failed': True, 'msg': api_rval}
            api_rval = oc_svc.get()
            if (api_rval['returncode'] != 0):
                return {'failed': True, 'msg': api_rval}
            return {'changed': True, 'results': api_rval, 'state': state}
        if oc_svc.needs_update():
            api_rval = oc_svc.update()
            if (api_rval['returncode'] != 0):
                return {'failed': True, 'msg': api_rval}
            api_rval = oc_svc.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.    [%s]' % state)}
