ansible - 使用 Ansible URI 模块的问题 - 即使添加了身份验证凭据,也会出现 401
问题描述
我正在使用 Ansible 的 URI 模块来调用一个简单的 GET 端点,但我收到如下所示的 401 错误消息。
这是剧本配置
- name: Elasticsearch Cluster health Check
uri:
url: https://elastichost:9200/_cluster/health?&pretty
url_password : xxxxxxx
url_username : xxxxxx
validate_certs : no
method: GET
body_format: json
force_basic_auth: yes
return_content: yes
headers:
Content-Type: "application/json"
register: showhealth
tags: NonProd
- name: Show Elasticsearch Health
debug: var=showhealth
tags: NonProd
有关如何解决的任何输入
解决方案
弹性的具体问题。elastic 是安全的,您需要令牌或证书才能连接到 api。
而且,您的用户需要正确的权利。
例子
- name: Create update_user
uri:
url: 'uri'
method: POST
user: elasticuser
body_format: json
headers:
Content-Type: application/json
body: '{{ item.body }}'
client_cert: 'certificate.crt'
client_key: 'certificate.key'
password: '{{ elastic_password }}'
validate_certs: false
return_content: true
推荐阅读
- .net - 没有突变的 F# 解决方案
- javascript - Sharepoint Office365 REST API 在浏览器中不起作用
- bluetooth-lowenergy - 如何使用 RxBluetooth 将多个订阅连接到 RxSwift 中的 Disposable?
- google-cloud-platform - 在 Google Cloud Platform 上实例化 VM(计算引擎)的脚本问题
- google-sheets - 最近几天的谷歌表格数据过滤器
- linux - 被动操作系统指纹更改为 MacOS
- ethereum - 以太坊DAPP——了解
- php - HTML 文本表单元素仅显示 PHP 数组中的第一个单词
- text - 如何创建文本文件、命名并填充内容?
- java - Microsoft Azure IoT 中心 (java) 通知“与服务器的连接丢失。重新连接 0 次。” 发送消息后