Ansible add entries to .htpassword
There are several ways to do this:
- Use template action and use template file
 - Use array of entries and loop with lininfile command
 - Use https://docs.ansible.com/ansible/latest/collections/community/general/htpasswd_module.html htpasswd module.
 
I decided to go with approach #2.
in variables
htpasswd:
  - user1:password1
  - user2:password2in the playbook
- name: set password file
      lineinfile:
        path: "{{ webroot }}/shared/.htpasswd"
        line: "{{ item }}"
        create: yes
      when: oxid.configuration == "production"
      loop: "{{ htpasswd }}"