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/kubernetes/prometheus/tasks/_create_auth_secret.yml

40 lines
918 B
YAML

---
- name: "Create empty htpswd file"
file:
path: "{{ htpasswd_file_path }}"
state: touch
- name: "Install latest passlib with pip"
pip: name=passlib
- 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 }}"
- name: "Read credentials out of htpasswd file"
ansible.builtin.slurp:
src: "{{ htpasswd_file_path }}"
register: credentials
- name: "Create prometheus secrets"
become: yes
kubernetes.core.k8s:
definition:
api_version: v1
kind: Secret
metadata:
namespace: "{{ namespace }}"
name: "{{ basic_auth_secret_name }}"
type: Opaque
data:
auth: "{{ credentials['content'] }}"
- name: "Delete htpasswd file"
become: yes
file:
path: "{{ htpasswd_file_path }}"
state: absent