---

- name: Install common packages for ubuntu/deb
  ansible.builtin.apt:
    name: "{{ packages }}"
    state: present
    update_cache: true
  vars:
    packages:
      - docker.io
      - python3-requests
      - runc
      - sg3-utils

- name: Install packages for old ubuntu
  ansible.builtin.apt:
    name: "{{ packages }}"
    state: present
  vars:
    packages:
      - python-crypto
      - python-cryptography
      - python-requests
  when: (ansible_facts['distribution'] == "Ubuntu" ) and
        ansible_distribution_major_version|int < 20

- name: Install package for ubuntu 20.04
  ansible.builtin.apt:
    name: "{{ packages }}"
    state: present
  vars:
    packages:
      - python-is-python3
  when: (ansible_facts['distribution'] == "Ubuntu" ) and
        (ansible_distribution_major_version|int >= 20)

- name: Install python crypto for ubuntu < 22
  ansible.builtin.apt:
    name: "{{ packages }}"
    state: present
  vars:
    packages:
      - python3-crypto
      - python3-cryptography
  when: (ansible_facts['distribution'] == "Ubuntu" ) and
        ansible_distribution_major_version|int < 22

- name: Install python crypto for ubuntu >= 22
  ansible.builtin.apt:
    name: "{{ packages }}"
    state: present
  vars:
    packages:
      - python3-pycryptodome
  when: (ansible_facts['distribution'] == "Ubuntu" ) and
        ansible_distribution_major_version|int >= 22
