2017-07-11 3 views
0

アシスタントv2.2.1.0In Anabilitiesどのように私は辞書から値を取得し、それらを事実に格納するのですか?

Search Dictionary Values in Ansibleで回答を変更するにはどうすればよいですか?

filenames_for_version: 
    1.0: 
    file1: "Hello.txt" 
    file2: "Goodbye.txt" 
    2.0: 
    file1: "HelloWorld.txt" 
    file2: "GoodbyeWorld.txt" 

は、今私が行うタスクを書きたい...

- name: Get the corresponding **file1** for the version 
    set_fact: f1_4_ver={{ what do I put here??? }} 
- name: Get the corresponding **file2** for the version 
    set_fact: f2_4_ver={{ what do I put here??? }} 

私はときに私CLIパラメータとしてバージョンを渡すことができるようにしたい:

私は辞書を持っています私は、バージョン= 1.0を渡すと、私は...

を得るように...

$ ansible-playbook -i "localhost," -c local get_filename_for_version.yml -e "version=1.0" 

、例えば、私の脚本を呼び出します

f1_4_ver=Hello.txt 
f2_4_ver=Goodbye.txt 

...と私は、バージョン= 2.0を渡すと、私が手... ..

{{ what do I put here??? }} 

にする必要がありますどのようなコード

f1_4_ver=HelloWorld.txt 
f2_4_ver=GoodbyeWorld.txt 

...私の一部タスク?

答えて

1
あなたは、変数/キー名にドットを使用することにより、トラブルを求めている

、しかし:

{{ filenames_for_version[version].file1 }} 
{{ filenames_for_version[version].file2 }} 
関連する問題