'run ansible idempotent code'

@staticmethod
def run_ansible(params, check_mode):

    rconfig = RouterConfig(params['name'], params['namespace'], params['kubeconfig'], {'default_cert': {'value': params['default_cert'], 'include': True}, 'cert_file': {'value': params['cert_file'], 'include': False}, 'key_file': {'value': params['key_file'], 'include': False}, 'images': {'value': params['images'], 'include': True}, 'latest_images': {'value': params['latest_images'], 'include': True}, 'labels': {'value': params['labels'], 'include': True}, 'ports': {'value': ','.join(params['ports']), 'include': True}, 'replicas': {'value': params['replicas'], 'include': True}, 'selector': {'value': params['selector'], 'include': True}, 'service_account': {'value': params['service_account'], 'include': True}, 'router_type': {'value': params['router_type'], 'include': False}, 'host_network': {'value': params['host_network'], 'include': True}, 'external_host': {'value': params['external_host'], 'include': True}, 'external_host_vserver': {'value': params['external_host_vserver'], 'include': True}, 'external_host_insecure': {'value': params['external_host_insecure'], 'include': True}, 'external_host_partition_path': {'value': params['external_host_partition_path'], 'include': True}, 'external_host_username': {'value': params['external_host_username'], 'include': True}, 'external_host_password': {'value': params['external_host_password'], 'include': True}, 'external_host_private_key': {'value': params['external_host_private_key'], 'include': True}, 'expose_metrics': {'value': params['expose_metrics'], 'include': True}, 'metrics_image': {'value': params['metrics_image'], 'include': True}, 'stats_user': {'value': params['stats_user'], 'include': True}, 'stats_password': {'value': params['stats_password'], 'include': True}, 'stats_port': {'value': params['stats_port'], 'include': True}, 'cacert_file': {'value': params['cacert_file'], 'include': False}, 'edits': {'value': params['edits'], 'include': False}})
    state = params['state']
    ocrouter = Router(rconfig, verbose=params['debug'])
    api_rval = ocrouter.get()
    if (state == 'list'):
        return {'changed': False, 'results': api_rval, 'state': state}
    if (state == 'absent'):
        if (not ocrouter.exists()):
            return {'changed': False, 'state': state}
        if check_mode:
            return {'changed': True, 'msg': 'CHECK_MODE:    Would    have    performed    a    delete.'}
        api_rval = ocrouter.delete()
        return {'changed': True, 'results': api_rval, 'state': state}
    if (state == 'present'):
        if (not ocrouter.exists()):
            if check_mode:
                return {'changed': True, 'msg': 'CHECK_MODE:    Would    have    performed    a    create.'}
            api_rval = ocrouter.create()
            if (api_rval['returncode'] != 0):
                return {'failed': True, 'msg': api_rval}
            return {'changed': True, 'results': api_rval, 'state': state}
        if (not ocrouter.needs_update()):
            return {'changed': False, 'state': state}
        if check_mode:
            return {'changed': False, 'msg': 'CHECK_MODE:    Would    have    performed    an    update.'}
        api_rval = ocrouter.update()
        if (api_rval['returncode'] != 0):
            return {'failed': True, 'msg': api_rval}
        return {'changed': True, 'results': api_rval, 'state': state}
