homeserver/roles/mgrote_minio_configure/tasks/user.yml
2024-11-09 11:13:11 +01:00

61 lines
1.9 KiB
YAML

---
- name: setup minio users
ansible.builtin.command: "{{ minio_client_bin }} --dp admin user add {{ minio_root_alias }} {{ item.name }} {{ item.secret }}"
loop: "{{ minio_users }}"
register: users
# mg@irantu ~
# > ./mc --dp admin accesskey list minio_root --all
# User: m-admin
# Access Keys:
# xxx, expires: 1 hour ago, sts: true
# xxx, expires: never, sts: false
# User: testuser1
# Access Keys:
# ekWgpsClIB5SDT2bJSqS, expires: never, sts: false
# 6ZP41ECPMGQM5IFXNN9E, expires: never, sts: false
# KFOB01AASUOQQ6PUZ0K2, expires: never, sts: false
# FYTEFK8ODQZOYFHCJUW7, expires: never, sts: false
# WIKS93B4323YI2WN0P5U, expires: never, sts: false
# User: testuser7
#
# mg@irantu ~
# > ./mc --dp admin accesskey list minio_root testuser7
# User: testuser7
# 1. check if user has access keys{wenn access}
# 2. when not create one, else skip
# whe exist, then display if param is set
- name: Get access keys for each user
ansible.builtin.command: "{{ minio_client_bin }} --dp admin accesskey list {{ minio_root_alias }} {{ item.name }}"
loop: "{{ minio_users }}"
register: keys
- name: "Debug: Print users with access keys"
ansible.builtin.debug:
msg: "User {{ item.item.name }} has access keys: {{ item.stdout }}"
loop: "{{ keys.results }}"
when: "'Access Keys:' in item.stdout"
- name: Create access keys for users without them
ansible.builtin.command: "{{ minio_client_bin }} --dp admin accesskey create {{ minio_root_alias }} {{ item.item.name }}"
loop: "{{ keys.results }}"
when: "'Access Keys:' not in item.stdout"
register: new_keys
- name: Output newly created access keys
ansible.builtin.debug:
msg: "New access key created for user {{ item.item.name }}: {{ item.stdout }}"
loop: "{{ new_keys.results }}"
when: item.item is defined
# mehrere keys pro user?
# wie ausgeben?
# no_log überall bei keys und users
# linter
# succssfu/changed_when