我正在尝试访问Ansible剧本中的一些Vault kv机密...
- hosts: localhost
connection: local
tasks:
- name: Retrieve secret/hello using native hashi_vault plugin
debug: msg="{{ lookup('hashi_vault', 'secret=secret/my-secret:foo token={{ vault_token }} url={{ vault_address }} ')}}"
我发现在使用kv存储引擎版本1来存储secret / my-secret的情况下,这种方法很好用。但是,当使用第二版时,我看到以下错误...
fatal: [localhost]: FAILED! => {"msg": "An unhandled exception occurred while running the lookup plugin 'hashi_vault'. Error was a <class 'ansible.errors.AnsibleError'>, original message: The secret secret/my-secret doesn't seem to exist for hashi_vault lookup"}
我做错了吗,还是hasi_vault查找插件不支持kv引擎的第二版?
干杯!
标记
答案 0 :(得分:0)
为此打开了一个拉取请求:https://github.com/ansible/ansible/pull/41132
我对您的解决方法做了一些改动:
password: "{{ lookup('hashi_vault', 'secret=secret/data/my_secret:data')['password']}}"
那样,您只需要修改一行即可。