Authored by Your Name

从extra vars获取vault变量

@@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
5 --- 5 ---
6 - hosts: 127.0.0.1 6 - hosts: 127.0.0.1
7 vars: 7 vars:
8 - qcloud_key: "{{ lookup('hashi_vault', 'secret=yoho/ops/qcloud token=27CLyZvYcqawMn7UALUMzRbH url=http://10.66.107.2:8200') }}" 8 + qcloud_key: "{{ lookup('hashi_vault', 'secret=yoho/ops/qcloud token='+'{{vault.token}}'+' url='+'{{vault.server}}') }}"
9 tasks: 9 tasks:
10 - name: Installing pip modules for using vault lookup 10 - name: Installing pip modules for using vault lookup
11 pip: name={{item}} 11 pip: name={{item}}
@@ -16,3 +16,5 @@ @@ -16,3 +16,5 @@
16 msg: "all info: {{ qcloud_key }}" 16 msg: "all info: {{ qcloud_key }}"
17 - debug: 17 - debug:
18 msg: "{{qcloud_key.SecretKey}}" 18 msg: "{{qcloud_key.SecretKey}}"
  19 +
  20 +#Test: ansible-playbook vault-test.yml -e '@extra_vars/all.yml'