0
私はかなり新しく、辞書プラグオプションを探そうとしています。 は私のプレイブックです.Jsonファイルをfrom_jsonモジュールを使用して辞書に変換しようとしていますが、次に特定のキーのみを印刷したいと考えています。 2番目の部分を達成できません。jsonファイルから作成された辞書の特定のキーにアクセスするためのwith_dict
ここのコードです:
hosts: localhost
vars:
jsonVar: "{{ lookup('file', 'ConfigData.json') | from_json }}"
tasks:
- name: print numbers
debug: msg=" {{ jsonVar.cpsSiteName }}"
debug: msg=" {{ jsonVar.dmsDataCacheAddress }}"
debug: msg=" {{ jsonVar.htsHttpClientIdleConnectionTimeout }}"
debug: msg=" {{ jsonVar.palConsulServerList }}"
debug: msg=" {{ jsonVar.prsMaxIncoReqProcTime }}"
debug: msg=" {{ jsonVar.prsMaxNumberOfExecutedScriptInstructions }}"
debug: msg=" {{ jsonVar.prsmschapv2Password }}"
出力は最後のデバッグ文が表示されますが。 変換された辞書から特定の変数にアクセスし、それを出力に印刷する方が賢明な方法があるかどうかを知りたい。
with_itemsを使用しようとしましたが、動作しません。 事前に助けてくれてありがとう。以下は
サンプルJSONファイルされる:
[email protected]:/etc/ansible# less ConfigData.json
{
"appSupCommonPullSendProxyAuthInfo":0,
"appSupCommonPullSendWebAuthInfo":0,
"appSupDdcSupervisionEnabled":1,
"appSupDdcSupervisionInterval":15,
"appSupDdcSupervisionMaxNoOfFailures":4,
"appSupDNS_number_consequtive_failures":5,
"appSupDNS_supervision_interval":60,
}