title: Ansible: convert a list with unicode to a list of strings (and compare them)
body: <p>I created a list with all the <strong>ansible group hosts</strong>.
  But when I print the list it contains unicode characters. <strong>u'text'</strong> instead of <strong>"text"</strong>
  Is there any efficient way to remove/convert this.
  I looked at other examples online but didn't succeed.</p>
  
  <p>Current (wrong) output with unicode characters: </p>
  
  <pre><code>ok: [server.name] =&gt; {
  "msg": " [u'all', u'coaster', u'aes', u'curo, u'dert', u'tomcatdeploy', u'implus-app', u'domain-top', u'tp-general', u'cdaes01', u'dicco-acc' .....
  </code></pre>
  
  <p>This should have an <strong>identical format like the following list</strong>. Because I want to compare them with diff.
  The values in the list itself are different, but should be formatted like:</p>
  
  <pre><code>ok: [server.name] =&gt; {
  "msg": [
      "tools", 
      "tools-api", 
      "adr-app", 
      "adr-app-e2j", 
      "aec", 
      "aec-copy", 
      "aes", 
      "aes1", 
      "aes2", 
      "aes3", 
      "ais", 
      "apiman", 
      "apiman-gateway-poc", 
      "apiman-manager", 
      "apiman-manager-poc", 
      "apollo-beheer-aangiftes", ...
  </code></pre>
  
  <p>Currently I'm using following code to fetch the list:</p>
  
  <pre><code>- name: register groups
    set_fact:
      inventory_groups: []  # empty list
      inventory_group_keys: "{{ groups.keys() |to_yaml}}" #|list
  
  - name: clean white spaces from list
    set_fact:
      inventory_groups: "{{ inventory_groups}} + ['{{item.strip()}}']"
    with_items: "{{inventory_group_keys[1:-2].split(',')}}"
  
  - name: print inventory_groups from local host for debugging
    debug:
      msg: " {{ inventory_groups }}"
  </code></pre>
  
  <p>The second list is fetched with an AWX api. 
  Also note that for some reason there seems to be a <strong>" before the [ bracket</strong> .
  Like highlighted below:</p>
  
  <pre><code>"msg": " [u'all',....
  </code></pre>
  
  <p>Which isn't in the first list. Any idea why this is. I assume this will give problems when comparing them later on.
  The way that I create the lists is identical.</p>