영사 kv 저장소에서 키 값을 검색하는 동안 오류가 발생했습니다.- 영사 kv 목록 재귀 및 키 값을 비교
우리는 키 값이 config/app-name/폴더 아래에 저장되어 있습니다. 많은 열쇠가 있습니다. 저는 영사로부터 모든 핵심 가치를 얻기 위해서 무언가를 원합니다. 는 그러나 다음과 같은 오류 점점 : 여기
PLAY [Adding host to inventory] **********************************************************************************************************************************************************
TASK [Adding new host to inventory] ******************************************************************************************************************************************************
changed: [localhost]
PLAY [Testing consul kv] *****************************************************************************************************************************************************************
TASK [show the lookups] ******************************************************************************************************************************************************************
fatal: [server1]: FAILED! => {"failed": true, "msg": "{{lookup('consul_kv','config/app-name/')}}: An unhandled exception occurred while running the lookup plugin 'consul_kv'. Error was a <class 'ansible.errors.AnsibleError'>, original message: Error locating 'config/app-name/' in kv store. Error was 500 No known Consul servers"}
PLAY RECAP *******************************************************************************************************************************************************************************
server1 : ok=0 changed=0 unreachable=0 failed=1
localhost : ok=1 changed=1 unreachable=0 failed=0
것은 내가 노력하고 코드입니다.
---
- name: Adding host to inventory
hosts: localhost
tasks:
- name: Adding new host to inventory
add_host:
name: "{{ target }}"
- name: Testing consul kv
hosts: "{{ target }}"
vars:
kv_info: "{{lookup('consul_kv','config/app-name/')}}"
become: yes
tasks:
- name: show the lookups
debug: msg="{{ kv_info }}"
그러나 폴더를 제거하고 폴더를 추가하는 것이 잘 작동합니다. 영사 클러스터에서 키 값을 가져 오는 것은 오류를 던지고 있습니다. 여기서 좀 더 나은 방법을 제안하십시오.
- name: remove folder from the store
consul_kv:
key: 'config/app-name/'
value: 'removing'
recurse: true
state: absent
- name: add folder to the store
consul_kv:
key: 'config/app-name/'
value: 'adding'
나는이 오류를 시도했지만 여전히 같은 오류가 발생했습니다. Ansible에서
---
- name: Adding host to inventory
hosts: localhost
environment:
ANSIBLE_CONSUL_URL: "http://consul-1.abcaa.com"
tasks:
- name: Adding new host to inventory
add_host:
name: "{{ target }}"
- name: show the lookups
debug: kv_info= "{{lookup('consul_kv','config/app-name/')}}"
감사합니다. 이 문제를 해결할 수있는 이상적인 방법을 제안 해 주시겠습니까? – ryan1506
제어 호스트에서 영사를 액세스 가능하게 만들고 올바른 URL을'ANSIBLE_CONSUL_URL' env 변수로 설정하십시오. 또는 데이터를 검색 할 수있는 Ansible에 대한 사용자 정의 영사 모듈을 검색하십시오. –
덕분에 나는 이것을 시도했지만 아직 500 명의 오류가없는 영사 서버를 가지고있다. – ryan1506