Skip to content

Instantly share code, notes, and snippets.

@jaohaohsuan
Created April 19, 2016 15:55
Show Gist options
  • Save jaohaohsuan/985e8add7d6ff0afed4368ab0e40c6df to your computer and use it in GitHub Desktop.
Save jaohaohsuan/985e8add7d6ff0afed4368ab0e40c6df to your computer and use it in GitHub Desktop.
post elasticsearch index mapping with ansible
---
- uri:
url: http://localhost:9200/stored-query
method: HEAD
status_code: 200,404
register: index_status
- debug: var=index_status
- debug: msg="{{ lookup('file','stored-query.mapping.json') }}"
- uri:
url: http://localhost:9200/stored-query
method: PUT
body: "{{ lookup('file','stored-query.mapping.json') }}"
HEADER_Content-Type: "application/json"
body_format: json
register: index_status
when: index_status.status == 404
- debug: var=index_status
@jaohaohsuan
Copy link
Author

Don't forget use body_format: json when sending http request with json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment