'run the ansible idempotent code'

@staticmethod
def run_ansible(params, check_mode):

    ocimage = OCImage(params['namespace'], params['registry_url'], params['image_name'], params['image_tag'], kubeconfig=params['kubeconfig'], verbose=params['debug'])
    state = params['state']
    api_rval = ocimage.get()
    if (state == 'list'):
        if (api_rval['returncode'] != 0):
            return {'failed': True, 'msg': api_rval}
        return {'changed': False, 'results': api_rval, 'state': 'list'}
    if (state == 'present'):
        if (not Utils.exists(api_rval['results'], params['image_name'])):
            if check_mode:
                return {'changed': False, 'msg': 'CHECK_MODE:    Would    have    performed    a    create'}
            api_rval = ocimage.create(params['registry_url'], params['image_name'], params['image_tag'])
            if (api_rval['returncode'] != 0):
                return {'failed': True, 'msg': api_rval}
            api_rval = ocimage.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.    {0}'.format(state)}
