'run the ansible idempotent code'

@staticmethod
def run_ansible(params, check_mode):

    ocsecret = OCSecret(params['namespace'], params['name'], params['type'], params['decode'], kubeconfig=params['kubeconfig'], verbose=params['debug'])
    state = params['state']
    api_rval = ocsecret.get()
    if (state == 'list'):
        return {'changed': False, 'results': api_rval, state: 'list'}
    if (not params['name']):
        return {'failed': True, 'msg': 'Please    specify    a    name    when    state    is    absent|present.'}
    if (state == 'absent'):
        if (not Utils.exists(api_rval['results'], params['name'])):
            return {'changed': False, 'state': 'absent'}
        if check_mode:
            return {'changed': True, 'msg': 'Would    have    performed    a    delete.'}
        api_rval = ocsecret.delete()
        return {'changed': True, 'results': api_rval, 'state': 'absent'}
    if (state == 'present'):
        if params['files']:
            files = params['files']
        elif params['contents']:
            files = Utils.create_tmp_files_from_contents(params['contents'])
        else:
            return {'failed': True, 'msg': 'Either    specify    files    or    contents.'}
        if (not Utils.exists(api_rval['results'], params['name'])):
            if check_mode:
                return {'changed': True, 'msg': 'Would    have    performed    a    create.'}
            api_rval = ocsecret.create(files, params['contents'], force=params['force'])
            if (files and params['delete_after']):
                Utils.cleanup([ftmp['path'] for ftmp in files])
            if (api_rval['returncode'] != 0):
                return {'failed': True, 'msg': api_rval}
            return {'changed': True, 'results': api_rval, 'state': 'present'}
        secret = ocsecret.prep_secret(params['files'], params['contents'], force=params['force'])
        if (secret['returncode'] != 0):
            return {'failed': True, 'msg': secret}
        if Utils.check_def_equal(secret['results'], api_rval['results'][0]):
            if (files and params['delete_after']):
                Utils.cleanup([ftmp['path'] for ftmp in files])
            return {'changed': False, 'results': secret['results'], 'state': 'present'}
        if check_mode:
            return {'changed': True, 'msg': 'Would    have    performed    an    update.'}
        api_rval = ocsecret.update(files, force=params['force'])
        if (secret and params['delete_after']):
            Utils.cleanup([ftmp['path'] for ftmp in files])
        if (api_rval['returncode'] != 0):
            return {'failed': True, 'msg': api_rval}
        return {'changed': True, 'results': api_rval, 'state': 'present'}
    return {'failed': True, 'changed': False, 'msg': ('Unknown    state    passed.    %s' % state), 'state': 'unknown'}
