---
- name: Find fixture ZIP files
  find:
    paths: "{{ util_base }}/fixtures"
    patterns: "*.zip"
    recurse: yes
  register: fixture_zip_files

- name: Extract fixture ZIP files
  unarchive:
    src: "{{ item.path }}"
    dest: "{{ app_base }}/stations"
    owner: azuracast
  with_items: "{{ fixture_zip_files.files }}"
  when: fixture_zip_files.matched > 0

- name: Find fixture SQL files
  find:
    paths: "{{ util_base }}/fixtures"
    patterns: "*.sql"
    recurse: yes
  register: fixture_sql_files

- name: Import fixture SQL files
  become: true
  become_user: azuracast
  shell: "php {{ util_base }}/cli.php dbal:import {{ item.path }}"
  with_items: "{{ fixture_sql_files.files }}"
  when: fixture_sql_files.matched > 0

- name: Clear AzuraCast Cache and Restart Stations
  become: true
  become_user: azuracast
  shell: php {{ util_base }}/cli.php cache:clear && php {{ util_base }}/cli.php azuracast:radio:restart
  when: fixture_zip_files.matched > 0 or fixture_sql_files.matched > 0
---
- name: Find fixture ZIP files
  find:
    paths: "{{ util_base }}/fixtures"
    patterns: "*.zip"
    recurse: yes
  register: fixture_zip_files

- name: Extract fixture ZIP files
  unarchive:
    src: "{{ item.path }}"
    dest: "{{ app_base }}/stations"
    owner: azuracast
  with_items: "{{ fixture_zip_files.files }}"
  when: fixture_zip_files.matched > 0

- name: Find fixture SQL files
  find:
    paths: "{{ util_base }}/fixtures"
    patterns: "*.sql"
    recurse: yes
  register: fixture_sql_files

- name: Import fixture SQL files
  become: true
  become_user: azuracast
  shell: "php {{ util_base }}/cli.php dbal:import {{ item.path }}"
  with_items: "{{ fixture_sql_files.files }}"
  when: fixture_sql_files.matched > 0
  register: fixture_sql_command_result
  failed_when: "'exception' in command_result.stdout"

- name: Clear AzuraCast Cache and Restart Stations
  become: true
  become_user: azuracast
  shell: php {{ util_base }}/cli.php cache:clear && php {{ util_base }}/cli.php azuracast:radio:restart
  when: fixture_zip_files.matched > 0 or fixture_sql_files.matched > 0
Add failure criteria to fixture install.
Add failure criteria to fixture install.

