title: In Ansible can I pass a dictionary to a cloud module as a variable
body: <p>I am using the ec2_asg cloud module in ansible to update an Auto-Scaling group.  I am trying to make this a role so I can apply this to multiple playbooks, and I was wondering if could pass in the tags values as variables.</p>
  
  <p>Without variables the asg task looks like:</p>
  
  <pre><code>ec2_asg:
    name: "test_app"    
    tags:
      - Environment: Production
      - Name: test_app  
  </code></pre>
  
  <p>And I know I could also do:</p>
  
  <pre><code>ec2_asg:
    name: {{asg_name}}"
    tags:
      - Environment: "{{asg_tag_env}}"
      - Name: "{{asg_tag_name}}"
  </code></pre>
  
  <p>But I'm curious if in my group_vars I can pass all of the tagging info in as a var, i.e.</p>
  
  <pre><code>asg_tags: "{'tags': {'Environment': Production, 'Name': test_app}}" #option1
  </code></pre>
  
  <p>or</p>
  
  <pre><code>asg_tags: "{'Environment': Production, 'Name': test_app}" #option2
  </code></pre>
  
  <p>When I try can call that in the ec2_asg module via</p>
  
  <pre><code> #option1
   ec2_asg
     name: "{{asg_name}}"
     "{{asg_tags}}"  
  </code></pre>
  
  <p>this doesn't seem to work, as the module doesn't understand the root index of the dictionary is the tags option you specify in the ec2_asg module.<br>  I just get a syntax error while loading YAML.</p>
  
  <p>and if I try</p>
  
  <pre><code> #option2
   ec2_asg
     name: "{{asg_name}}"
     tags: "{{asg_tags}}"
  </code></pre>
  
  <p>I get back an error from ansible stating:<br> 
  for k,v in tag.items():\nAttributeError: 'str' object has no attribute 'items'\n"</p>
  
  <p>Either this isn't supported, or I'm not sure how to structure the variable so the ec2_asg module reads in the tags correctly and knows how to apply them.</p>