title: Ansible - How to set a var with a loop
body: <p>I would like to create a complex var (nginx_ssl_vhosts_list) with a loop from another simple var (reverse_proxy_ssl) but I'm unable to get this to work. Is it possible to have something like the following code or shall I use a custom plugin?</p>
  
  <p>Here is what how I thought it would have worked:</p>
  
  <pre><code>- hosts: localhost
    gather_facts: no
    connection: local
    vars:
      reverse_proxy_ssl:
        - name: foo.org
          frontport: 443
          fronturl : /
          backend: http://192.168.1.1:8080
        - name: bar.org
          frontport: 443
          fronturl : /
          backend: http://192.168.1.2:443
      nginx_ssl_vhosts_list:
        - listen: "{{ item.frontport }} ssl"
          server_name: "{{ item.name }}"
          access_log: "{{ item.name }}.access.log"
          error_log: "{{ item.name }}.error.log"
          extra_parameters: |
            location {{ item.fronturl }} {
              proxy_pass {{ item.backend }};
            }
            ssl_certificate     {{ item.name }}.crt;
            ssl_certificate_key {{ item.name }}.key;
        with_items: "{{ reverse_proxy_ssl }}"
    tasks:
      - debug: msg="{{ nginx_ssl_vhosts_list }}"
  </code></pre>