---
- block:
  - name: Create python2.7 directory
    file:
      path: /etc/python2.7
      state: directory
      owner: root
      group: root
      mode: '755'

  - name: Write sitecustomize.py
    template:
      src: sitecustomize.py
      dest: /etc/python2.7/sitecustomize.py
      owner: root
      group: root
      mode: '644'
      backup: yes

  - name: Install python (2.7, 3.4, 3.6) from apt
    apt:
      name:
        - python-dev
        - python3-dev
        - python3.6-dev
      cache_valid_time: "{{ apt_cache_valid_time }}"
    when: os_release_name == "trusty"

  - block:
    - name: Install python (2.7, 3.6, 3.8) from apt
      apt:
        name:
          - python2.7-dev
          - python3.6-dev
          - python3.8-dev
        cache_valid_time: "{{ apt_cache_valid_time }}"

    - name: Install python-is-python2 from apt
      apt:
        name:
          - python-is-python2
        cache_valid_time: "{{ apt_cache_valid_time }}"
    when: os_release_name == "focal"

  become: yes
