'run the idempotent ansible code'

@staticmethod
def run_ansible(params, check_mode):

    node_selector = None
    if (params['node_selector'] is not None):
        node_selector = ','.join(params['node_selector'])
    pconfig = ProjectConfig(params['name'], 'None', params['kubeconfig'], {'admin': {'value': params['admin'], 'include': True}, 'admin_role': {'value': params['admin_role'], 'include': True}, 'description': {'value': params['description'], 'include': True}, 'display_name': {'value': params['display_name'], 'include': True}, 'node_selector': {'value': node_selector, 'include': True}})
    oadm_project = OCProject(pconfig, verbose=params['debug'])
    state = params['state']
    api_rval = oadm_project.get()
    if (state == 'list'):
        return {'changed': False, 'results': api_rval['results'], 'state': state}
    if (state == 'absent'):
        if oadm_project.exists():
            if check_mode:
                return {'changed': True, 'msg': 'CHECK_MODE:    Would    have    performed    a    delete.'}
            api_rval = oadm_project.delete()
            if (api_rval['returncode'] != 0):
                return {'failed': True, 'msg': api_rval}
            return {'changed': True, 'results': api_rval, 'state': state}
        return {'changed': False, 'state': state}
    if (state == 'present'):
        if (not oadm_project.exists()):
            if check_mode:
                return {'changed': True, 'msg': 'CHECK_MODE:    Would    have    performed    a    create.'}
            api_rval = oadm_project.create()
            api_rval = oadm_project.get()
            if (api_rval['returncode'] != 0):
                return {'failed': True, 'msg': api_rval}
            return {'changed': True, 'results': api_rval, 'state': state}
        if oadm_project.needs_update():
            if check_mode:
                return {'changed': True, 'msg': 'CHECK_MODE:    Would    have    performed    an    update.'}
            api_rval = oadm_project.update()
            if (api_rval['returncode'] != 0):
                return {'failed': True, 'msg': api_rval}
            api_rval = oadm_project.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, 'changed': False, 'msg': ('Unknown    state    passed.    [%s]' % state)}
