title: In Ansible how do I get values from a dictionary and store them in a fact?
body: <p>Ansible v2.2.1.0</p>
  
  <p>How do I modify the answer in <a href="https://stackoverflow.com/questions/41581273/search-dictionary-values-in-ansible#">Search Dictionary Values in Ansible</a> to do this?</p>
  
  <p>I have a dictionary:</p>
  
  <pre><code>filenames_for_version:
    1.0:
      file1: "Hello.txt"
      file2: "Goodbye.txt"
    2.0:
      file1: "HelloWorld.txt"
      file2: "GoodbyeWorld.txt"
  </code></pre>
  
  <p>Now I want to write a task that does...</p>
  
  <pre><code>- 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??? }}
  </code></pre>
  
  <p>I want to be able to pass the version as a CLI parameter when I call my playbook, e.g.,</p>
  
  <pre><code>$ ansible-playbook -i "localhost," -c local get_filename_for_version.yml -e "version=1.0"
  </code></pre>
  
  <p>...such that if I pass version=1.0, I get...</p>
  
  <pre><code>f1_4_ver=Hello.txt
  f2_4_ver=Goodbye.txt
  </code></pre>
  
  <p>...and if I pass version=2.0, I get...</p>
  
  <pre><code>f1_4_ver=HelloWorld.txt
  f2_4_ver=GoodbyeWorld.txt
  </code></pre>
  
  <p>What code should be in the..</p>
  
  <pre><code>{{ what do I put here??? }}
  </code></pre>
  
  <p>...part of my tasks?</p>