'run the ansible idempotent code'

@staticmethod
def run_ansible(params, check_mode):

    rconfig = ServiceAccountConfig(params['name'], params['namespace'], params['kubeconfig'], params['secrets'], params['image_pull_secrets'])
    oc_sa = OCServiceAccount(rconfig, verbose=params['debug'])
    state = params['state']
    api_rval = oc_sa.get()
    if (state == 'list'):
        return {'changed': False, 'results': api_rval['results'], 'state': 'list'}
    if (state == 'absent'):
        if oc_sa.exists():
            if check_mode:
                return {'changed': True, 'msg': 'Would    have    performed    a    delete.'}
            api_rval = oc_sa.delete()
            return {'changed': True, 'results': api_rval, 'state': 'absent'}
        return {'changed': False, 'state': 'absent'}
    if (state == 'present'):
        if (not oc_sa.exists()):
            if check_mode:
                return {'changed': True, 'msg': 'Would    have    performed    a    create.'}
            api_rval = oc_sa.create()
            if (api_rval['returncode'] != 0):
                return {'failed': True, 'msg': api_rval}
            api_rval = oc_sa.get()
            if (api_rval['returncode'] != 0):
                return {'failed': True, 'msg': api_rval}
            return {'changed': True, 'results': api_rval, 'state': 'present'}
        if oc_sa.needs_update():
            api_rval = oc_sa.update()
            if (api_rval['returncode'] != 0):
                return {'failed': True, 'msg': api_rval}
            api_rval = oc_sa.get()
            if (api_rval['returncode'] != 0):
                return {'failed': True, 'msg': api_rval}
            return {'changed': True, 'results': api_rval, 'state': 'present'}
        return {'changed': False, 'results': api_rval, 'state': 'present'}
    return {'failed': True, 'changed': False, 'msg': ('Unknown    state    passed.    %s' % state), 'state': 'unknown'}
