---
# file: roles/minio/tasks/minio_anonymous_policies.yml

- name: "mcli anonymous get minio_on_localhost/{{ item.path }}"
  ansible.builtin.command: "mcli anonymous get minio_on_localhost/{{ item.path }} --json"
  register: minio_anonyous_policy_get
  changed_when: false
  check_mode: false

- name: "mcli anonymous set {{ item.permission }} minio_on_localhost/{{ item.path }}"
  ansible.builtin.command: "mcli anonymous set {{ item.permission }} minio_on_localhost/{{ item.path }}"
  when: item.permission != (minio_anonyous_policy_get.stdout|from_json|json_query('permission'))
