title: How to format a dict to a string in ansible
body: <p>I want to format a dict in ansible like so,</p>
  <p>from</p>
  <pre class="lang-yaml prettyprint-override"><code>{'a': 1, 'b': 2, 'c': 3}
  </code></pre>
  <p>to</p>
  <pre class="lang-yaml prettyprint-override"><code>'a=1,b=2,c=3'
  </code></pre>
  <p>and have to set it as an environment variable in a block like so,</p>
  <pre class="lang-yaml prettyprint-override"><code>vars:
    test_env:
      a: 1
      b: 2
      c: 3
  
  - block:
      # tasks
    environment:
      SOME_ENV: 'a=1,b=2,c=3'
  </code></pre>
  <p>here I want to convert <code>test_env</code> dict to <code>'a=1,b=2,c=3'</code>
  I can not set the fact to modify the dict and then set it to the <code>SOME_ENV</code> because <code>environment</code> is a different clause, maybe I can modify the dict in the <code>vars</code> clause but is there any other solution?</p>