'run the idempotent ansible code'

@staticmethod
def run_ansible(params, check_mode):

    params['hostnames'] = [host for host in params['hostnames'] if isinstance(host, string_types)]
    config = CAServerCertConfig(params['kubeconfig'], params['debug'], {'cert': {'value': params['cert'], 'include': True}, 'hostnames': {'value': ','.join(params['hostnames']), 'include': True}, 'overwrite': {'value': True, 'include': True}, 'key': {'value': params['key'], 'include': True}, 'signer_cert': {'value': params['signer_cert'], 'include': True}, 'signer_key': {'value': params['signer_key'], 'include': True}, 'signer_serial': {'value': params['signer_serial'], 'include': True}, 'expire_days': {'value': params['expire_days'], 'include': True}, 'backup': {'value': params['backup'], 'include': False}})
    server_cert = CAServerCert(config)
    state = params['state']
    if (state == 'present'):
        if ((not server_cert.exists()) or params['force']):
            if check_mode:
                return {'changed': True, 'msg': 'CHECK_MODE:    Would    have    created    the    certificate.', 'state': state}
            api_rval = server_cert.create()
            if (api_rval['returncode'] != 0):
                return {'failed': True, 'msg': api_rval}
            return {'changed': True, 'results': api_rval, 'state': state}
        api_rval = server_cert.get()
        return {'changed': False, 'results': api_rval, 'state': state}
    return {'failed': True, 'msg': ('Unknown    state    passed.    %s' % state)}
