- name: Ensure tox is installed
  include_role:
    name: ensure-tox

- name: Allow git to read tempest directory
  become: yes
  command: git config --system --add safe.directory {{devstack_base_dir}}/tempest

- name: Prepare tempest venv
  become: yes
  command: tox -r --notest -efull
  args:
    chdir: "{{devstack_base_dir}}/tempest"

- name: Allow git to read plugin directories
  become: yes
  command: git config --system --add safe.directory {{item}}
  with_items: "{{plugins_paths}}"

- name: Install plugins
  become: yes
  command:
    cmd: >
      tox -evenv-tempest --
      pip install {{ item }}
      --constraint {{ ansible_user_dir }}/{{ zuul.projects['opendev.org/openstack/requirements'].src_dir }}/upper-constraints.txt
  with_items: "{{ plugins_paths }}"
  args:
    chdir: "{{devstack_base_dir}}/tempest"
  when: plugins_paths is defined

- name: List installed tempest plugins
  become: yes
  command: tox -evenv-tempest -- tempest list-plugins
  args:
    chdir: "{{devstack_base_dir}}/tempest"
