首页 > 解决方案 > 需要获取语法来获取键值对

问题描述

TASK [hashi-bulk : pinting] ****************************************************
ok: [localhost] => {
    "msg": [
        "Pod000/windows:{'windows_password': 'Passw0rd!','windows_username': 'Administrator'}",
        " Pod000/ad_cred : {'ad_password': 'Passw0rd!','ad_username': 'SANPADIEP230'}"
    ]
}
TASK [hashi-bulk : setin] ******************************************************
fatal: [localhost]: FAILED! => {"msg": "|combine expects dictionaries, got AnsibleUndefined"}


**I want the value Pod000/windows and Pod000/ad_cred as key and {'windows_password': 'Passw0rd!','windows_username': 'Administrator'} as value.**

- name: pinting
  debug:
    msg: "{{ var_json_secret }}"    
- name: setin
  set_fact: 
     secret: "{{ secret | default([]) | combine(dic[item]) }}"
  with_items: var_json_secret
- name: test
  debug: 
    var: secret

在这里我想得到语法

标签: ansibleansible-2.xansible-factsansible-template

解决方案


推荐阅读