vhosts with htpasswd

13 views
Skip to first unread message

Nico K.

unread,
Aug 4, 2015, 5:15:01 AM8/4/15
to Ansible Project
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:

<snippet>
  auth_basic_user_file /some/path/user1.htpasswd;
....
....
    auth_basic_user_file /some/path/user2.htpasswd;
</snippet>

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

Reply all
Reply to author
Forward
0 new messages