GET 쿼리를 실행하면 정상적으로 실행됩니다. 예를 들어
- 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
회신하다:
# 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"
}
}
}
그러나 아래와 같이 PUT 쿼리를 실행하면 "response.content": "VARIABLE IS NOT DEFINED!"라는 오류가 발생합니다.
이것은 스크립트입니다
- 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
이건 오류야
# 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!"
}
어떤 변수를 참조하는지 또는 쿼리가 출력에서 실행되는지 확실하지 않습니다.