You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
hetzner-ansible/roles/sma_deploy/tasks/htpasswd.yml

28 lines
796 B
YAML

---
- name: "Create empty htpswd file"
ansible.builtin.file:
path: "{{ htpasswd_file_path }}"
state: touch
mode: '0600'
- name: "Add a user and password to empty htpswd file>"
community.general.htpasswd:
path: "{{ htpasswd_file_path }}"
name: "{{ basic_auth_username }}"
password: "{{ basic_auth_password }}"
mode: '0600'
- name: "Read credentials out of htpasswd file"
ansible.builtin.slurp:
src: "{{ htpasswd_file_path }}"
register: "credentials"
- name: "Delete htpasswd file"
ansible.builtin.file:
path: "{{ htpasswd_file_path }}"
state: absent
- name: "Setting htpasswd to <{{ credentials_name }}>" ## noqa var-naming
ansible.builtin.set_fact: "{{ credentials_name }}={{ credentials.content | b64decode | trim | replace('$','$$') }}"