---
- name: Install Library
  apt:  "name={{ item }} state=latest update_cache=yes"
  with_items:
    - libltdl7
    - python
    - python3-pip
  tags: docker_init

- name: Pip Install docker-py Module
  pip:
    name: docker-py
  tags: docker_init


- name: Copy Install File
  copy: src=docker.deb dest=/tmp/docker.deb owner=root group=root mode=0744
  tags: docker_init

- name: Install dokcer.deb package
  apt:
    deb: /tmp/docker.deb
  tags: docker_init

- name: Restart Docker Service
  systemd:
    state: restarted
    daemon_reload: yes
    enabled: yes
    name: docker.service
  tags: docker_init


- name: Log into registry.myregistry.com:5000
  docker_login:
    registry: registry.myregistry.com:5000
    username: username
    password: password
    reauthorize: yes
  tags: docker_init


- name: Pull app Image
  docker_image:
    name: registry.myregistry.com:5000/app:1.0
  tags: docker_init

- name: Retag image
  shell: docker tag registry.myregistry.com:5000/app:1.0  app:1.0
  tags: docker_init



