title: Set fact with dynamic key name in ansible
body: <p>I am trying to shrink several chunks of similar code which looks like:</p>
  <pre><code>- ... multiple things is going here
    register: list_register
  - name: Generating list
    set_fact: my_list=&quot;{{ list_register.results | map(attribute='ansible_facts.list_item') | list }}&quot;
  
  # the same code repeats...
  </code></pre>
  <p>The only difference between them is <em>list name</em> instead of <code>my_list</code>.</p>
  <p>In fact, I want to do this:</p>
  <pre><code>set_fact:
    &quot;{{ some var }}&quot; : &quot;{{ some value }}&quot;
  </code></pre>
  <p>I came across <a href="http://grokbase.com/t/gg/ansible-project/159nedkjft/setting-fact-name-dynamically-in-set-fact" rel="nofollow noreferrer">this post</a> but didn't find any answer here.</p>
  <p><strong>Is it possible to do so or is there any workaround?</strong></p>