'perform the idempotent crud operations'

@staticmethod
def run_ansible(params):

    yamlfile = Yedit(filename=params['src'], backup=params['backup'], separator=params['separator'])
    state = params['state']
    if params['src']:
        rval = yamlfile.load()
        if ((yamlfile.yaml_dict is None) and (state != 'present')):
            return {'failed': True, 'msg': ('Error    opening    file    [{}].        Verify    that    the    '.format(params['src']) + 'file    exists,    that    it    is    has    correct    permissions,    and    is    valid    yaml.')}
    if (state == 'list'):
        if params['content']:
            content = Yedit.parse_value(params['content'], params['content_type'])
            yamlfile.yaml_dict = content
        if params['key']:
            rval = (yamlfile.get(params['key']) or {})
        return {'changed': False, 'result': rval, 'state': state}
    elif (state == 'absent'):
        if params['content']:
            content = Yedit.parse_value(params['content'], params['content_type'])
            yamlfile.yaml_dict = content
        if params['update']:
            rval = yamlfile.pop(params['key'], params['value'])
        else:
            rval = yamlfile.delete(params['key'])
        if (rval[0] and params['src']):
            yamlfile.write()
        return {'changed': rval[0], 'result': rval[1], 'state': state}
    elif (state == 'present'):
        if params['content']:
            content = Yedit.parse_value(params['content'], params['content_type'])
            if ((yamlfile.yaml_dict == content) and (params['value'] is None)):
                return {'changed': False, 'result': yamlfile.yaml_dict, 'state': state}
            yamlfile.yaml_dict = content
        edits = []
        _edit = {}
        if (params['value'] is not None):
            _edit['value'] = params['value']
            _edit['value_type'] = params['value_type']
            _edit['key'] = params['key']
            if params['update']:
                _edit['action'] = 'update'
                _edit['curr_value'] = params['curr_value']
                _edit['curr_value_format'] = params['curr_value_format']
                _edit['index'] = params['index']
            elif params['append']:
                _edit['action'] = 'append'
            edits.append(_edit)
        elif (params['edits'] is not None):
            edits = params['edits']
        if edits:
            results = Yedit.process_edits(edits, yamlfile)
            if (results['changed'] and params['src']):
                yamlfile.write()
            return {'changed': results['changed'], 'result': results['results'], 'state': state}
        if params['src']:
            rval = yamlfile.write()
            return {'changed': rval[0], 'result': rval[1], 'state': state}
        return {'changed': False, 'result': yamlfile.yaml_dict, 'state': state}
    return {'failed': True, 'msg': 'Unkown    state    passed'}
