---

# Cleanup old configurations and software

- hosts: installation
  become: no
  vars_files:
    - "{{ play_dir }}/vars/common.yml"
    - "{{ play_dir }}/roles/versions.yml"

  roles:

    - role: remove-apps
      old_apps:
        - /ldsm
        - /federationdb

- hosts: managed
  become: yes
  vars_files:
    - "{{ play_dir }}/vars/common.yml"
    - "{{ play_dir }}/roles/versions.yml"

  tasks:
    - name: Remove old files
      file:
        path: "{{ item }}"
        state: absent
      with_items:
        - /srv/docker/postgres
        - /opt/analytics-database/migration/V1.01__r-linear-regression-create-result-table.sql
        - /opt/analytics-database/migration/V1.02__r-box-stats-create-result-table.sql

    - name: Remove old Docker images
      docker_image:
        name: "{{ item }}"
        state: absent
      with_items:
        - postgres:9.3.9
        - postgres:9.4.4

---

# Cleanup old configurations and software

- hosts: installation
  become: no
  vars_files:
    - "{{ play_dir }}/vars/common.yml"
    - "{{ play_dir }}/roles/versions.yml"

  roles:

    - role: remove-apps
      old_apps:
        - /ldsm
        - /federationdb

- hosts: managed
  become: yes
  vars_files:
    - "{{ play_dir }}/vars/common.yml"
    - "{{ play_dir }}/roles/versions.yml"

  tasks:
    - name: Remove old files
      file:
        path: "{{ item }}"
        state: absent
      with_items:
        - /srv/docker/postgres
        - /opt/analytics-database/migration/V1.01__r-linear-regression-create-result-table.sql
        - /opt/analytics-database/migration/V1.02__r-box-stats-create-result-table.sql

    - name: Install docker-py to control Docker from Ansible
      apt: pkg=python-docker state=present

    - name: Remove old Docker images
      docker_image:
        name: "{{ item }}"
        state: absent
      with_items:
        - postgres:9.3.9
        - postgres:9.4.4

Install docker-py to control Docker from Ansible
Install docker-py to control Docker from Ansible
