---

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

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

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

- name: Create default bucket
  shell: |
    . {{ python_dist_path }}/bin/activate
    {{ python_dist_path }}/bin/awslocal s3api create-bucket --bucket {{ isic_upload_bucket_name }}

---

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

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

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

- name: Wait for localstack to be listening
  wait_for:
    port: 4572  # S3 port
    timeout: 20

- name: Create default bucket
  shell: |
    . {{ python_dist_path }}/bin/activate
    {{ python_dist_path }}/bin/awslocal s3api create-bucket --bucket {{ isic_upload_bucket_name }}

Fix randomly occurring race condition with localstack role
Fix randomly occurring race condition with localstack role
