Sample Header Ad - 728x90

run put queries on Elasticsearch host from ansible host

0 votes
0 answers
184 views
When I run any GET queries, it runs fine. for instance - name: run curl query on ES host uri: url: "http://localhost:9200" method: GET return_content: yes url_username: some_elastic_user url_password: elastic_pass register: response - debug: var: response.content RESPONSE: # ansible-playbook -i inv.txt getquery.yml PLAY [es] ******************************************************************************************************************************************** TASK [esquery : run curl query on ES host] ***************************************************************************************************** ok: [es1] TASK [esquery : debug] ************************************************************************************************************************* ok: [es1] => { "response.content": { "cluster_name": "elastic", "cluster_uuid": "evEg5b8aQiW-ewNdbYG5-A", "name": "es1", "tagline": "You Know, for Search", "version": { "build_date": "2020-06-14T19:35:50.234439Z", "build_flavor": "default", "build_hash": "757314695644ea9a1dc2fecd26d1a43856725e65", "build_snapshot": false, "build_type": "tar", "lucene_version": "8.5.1", "minimum_index_compatibility_version": "6.0.0-beta1", "minimum_wire_compatibility_version": "6.8.0", "number": "7.8.0" } } } However, when I run PUT query like below, it gives ERROR: "response.content": "VARIABLE IS NOT DEFINED!" here's playbook - name: set elasticsearch index settings uri: url: "http://localhost:9200/*/_settings" method: PUT headers: Content-Type: "application/json" body_format: json body: index: auto_expand_replicas: "0-all" url_username: some_elastic_user url_password: elastic_pass register: response - debug: var: response.content Here's error # ansible-playbook -i inv.txt putquery.yml PLAY [es] ******************************************************************************************************************************************** TASK [esquery : set elasticsearch index settings] ********************************************************************************************** ok: [es1] TASK [esquery : debug] ************************************************************************************************************************* ok: [es1] => { "response.content": "VARIABLE IS NOT DEFINED!" } not sure what variable it is refering to, and not sure whether query ran or not from output.
Asked by Sollosa (1993 rep)
Aug 4, 2023, 05:54 AM