vhosts with htpasswd

hi guys,

I am creating my htpasswd files in the following manner which works fine:

vhosts:
sites:

  • name: my_site
    htpasswd:

  • name: user1
    pass: pass1

  • name: user2
    pass: pass2

  • name: Create htpasswd file
    htpasswd:
    path: “{ item.1.name }}.htpasswd”
    name: “{{ item.1.name }}”
    password: “{{ item.1.password }}”

    with_subelements:

  • vhosts.sites

  • htpasswd
    when: item.1 is defined

However in the vhost template itself I have several locations where I want to refer to either user1 or user2, for example:

auth_basic_user_file /some/path/user1.htpasswd; .... .... auth_basic_user_file /some/path/user2.htpasswd;

currently these references are hardcoded, but I would really like to have a way where I could refer to them in my list not by index (Since I don’t know which entry it is going to be) but by name).

Hope someone can help!

Thanks,
Nico