title: ansible: create a list from comma separated string
body: <p>I want to create a list from comma separated string to pass to loop in ansible, sometime variable can have only one value also</p>
  
  <p>var1=test1,test2 and it can be var1=test1 also</p>
  
  <p>here is my code</p>
  
  <pre><code>- name: Separate facts
    set_fact: groups="{{ var1.split(',') }}"
  
  - name: delete 
    gcp_compute_instance_group:
      name: "{{  item  }}"
      zone: xxx
      project: xxx
      auth_kind: serviceaccount
      service_account_file: xxx
      state: absent
    loop: "{{ groups }}" 
  </code></pre>
  
  <p>this doesn't work, how can i achieve my requirement </p>