---

- name: Install awscli
  pip:
    name: awscli
    virtualenv: "{{ python_dist_path }}"

- name: Download minio
  get_url:
    url: https://dl.minio.io/server/minio/release/linux-amd64/minio
    dest: /opt/minio
    mode: 0775
  become: true

- name: Daemonize minio
  template:
    src: "minio.service.j2"
    dest: "/etc/systemd/system/minio.service"
  become: true

- name: Start minio
  systemd:
    name: minio
    daemon_reload: true
    enabled: true
    state: started
  become: true

- name: Wait for minio to be listening
  wait_for:
    port: 9000
    timeout: 20

- name: Create default bucket
  command: >-
    {{ python_dist_path }}/bin/aws
    --endpoint-url http://localhost:9000
    s3api create-bucket
    --bucket {{ isic_upload_bucket_name }}
  environment:
    AWS_ACCESS_KEY_ID: accesskey
    AWS_SECRET_ACCESS_KEY: secretkey
  args:
    creates: "{{ ansible_user_dir }}/.bucket.created"
  register: bucket_create

- name: Set default bucket marker
  file:
    path: "{{ ansible_user_dir }}/.bucket.created"
    state: touch
  when: bucket_create.changed

---

- name: Install awscli
  pip:
    name: awscli
    virtualenv: "{{ python_dist_path }}"

- name: Download minio
  get_url:
    url: https://dl.minio.io/server/minio/release/linux-amd64/minio
    dest: /opt/minio
    mode: 0775
  become: true

- name: Daemonize minio
  template:
    src: "minio.service.j2"
    dest: "/etc/systemd/system/minio.service"
  become: true

- name: Start minio
  systemd:
    name: minio
    daemon_reload: true
    enabled: true
    state: started
  become: true

- name: Wait for minio to be listening
  wait_for:
    port: 9000
    timeout: 20

- name: Create default bucket
  file:
    path: "{{ ansible_user_dir }}/minio-data/{{ isic_upload_bucket_name }}"
    state: directory

Simplify minio bucket creation logic
Simplify minio bucket creation logic
