简体   繁体   中英

automate elastic enterprise with ansible playbook

I would really like someone's help on this platform to help me with this.

Task: I want to deploy with ansible playbooks elastic search deployment template, instead of creating it manually in the console, I would love to automate the flow.

Here is the command to execute this via cli, but what would that look like if I were to translate this below command into an ansible playbook?

curl -k -X POST -H "Authorization: ApiKey $ECE_API_KEY" https://$COORDINATOR_HOST:12443/api/v1/deployments -H 'content-type: application/json' -d '

I have tried this but no success:

- 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

Here was the answer just in case someone ever stumbled into this situation:

---
- 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 }}"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM