---
- name: "STRESS-SETUP: Install Python Dependencies"
  hosts: all
  gather_facts: yes
  vars_files:
    - "group_vars/all/generated_vars.stress.yml"
    - "group_vars/all/vault.yml"
  pre_tasks:
    - name: Ensure python3-pip is installed
      block:
        - name: Install prerequisites for managing repositories
          ansible.builtin.apt:
            name: software-properties-common
            state: present
            update_cache: yes

        - name: Ensure universe repository is enabled
          ansible.builtin.apt_repository:
            repo: "deb http://archive.ubuntu.com/ubuntu {{ ansible_lsb.codename }} universe"
            state: present
            update_cache: yes

        - name: Install python3-pip
          ansible.builtin.apt:
            name: python3-pip
            state: present
      become: yes

  tasks:
    - name: Install required Python packages
      ansible.builtin.pip:
        name:
          - python-dotenv
          - aria2p
          - tabulate
          - redis
          - PyYAML
          - aiothrift
          - PySocks
        state: present
      become: yes
      environment:
        PIP_BREAK_SYSTEM_PACKAGES: "1"
