---
- hosts: all
  tasks:
  - name: Update aptitude
    apt: {name: aptitude}
    become: true
    register: result  
    
  - name: update and upgrade
    apt: {update_cache: true, upgrade: true, autoremove: true, force: true}
    become: true
    register: result   
    
  - name: install pre-req
    apt: name="{{ item }}" state=latest
    with_items: [python, curl, python-pip, apt-transport-https, linux-image-extra-virtual,
      linux-image-extra-4.4.0-97-generic, ca-certificates, software-properties-common]
    become: true
    register: result
    
  - name: Add key
    apt_key: {url: 'https://download.docker.com/linux/ubuntu/gpg', state: present}
    become: true
    register: result
    
  - name: add repo
    apt_repository: {repo: 'deb https://download.docker.com/linux/ubuntu xenial stable', state: present}
    become: true
    register: result   
    
  - name: update and upgrade
    apt: {update_cache: true, upgrade: true, autoremove: true, force: true}
    become: true
    register: result  
    
  - name: install docker-ce
    apt: name="{{ item }}" state=latest
    with_items: [docker-ce]
    become: true
    
  - pip:
        name: docker-py    
    become: true
    
    
  - name: Log into DockerHub
    docker_login:
      username: USER
      password: PASSS 
      email: XXXXX
      config_path: /home/vm_user/.docker/config.json
    become: true
    
  - file:
      path: /home/vm_user/.docker/config.json
      owner: vm_user
    become: true      