我真的很希望有人在这个平台上帮助我。
任务:我想使用ansible playbooks弹性搜索部署模板部署,而不是在控制台中手动创建它,我很想让流程自动化。
下面是通过cli执行这个命令的命令,但是如果我将下面的命令转换成一个ansible剧本,这会是什么样子呢?
curl -k -X POST -H "Authorization: ApiKey $ECE_API_KEY" https://$COORDINATOR_HOST:12443/api/v1/deployments -H 'content-type: application/json' -d '
我试过了,但没有成功:
- hosts: primary
become: true
tasks:
- name: Create Deployment
uri:
url: "https://eastus2.azure.elastic-dev.xxx.com/deployments/create"
method: POST
user: admin
password: password
body: "{{ lookup('file','deployments.json') }}"
force_basic_auth: yes
status_code: 200
body_format: json发布于 2022-05-23 13:14:08
以下是一个答案,以防有人跌跌撞撞地遇到这种情况:
---
- hosts: primary
become: true
tasks:
- name: Create Deployment
uri:
url: "{{ url_deploy }}"
method: POST
body: "{{ lookup('file','deployments.json') }}"
force_basic_auth: yes
status_code: 201
body_format: json
headers:
Content-Type: "application/json"
Authorization: "ApiKey {{ ECE_API_KEY }}"https://stackoverflow.com/questions/72309701
复制相似问题