---

- name: CentOS
  include: centos.yml
  when: 'ansible_distribution == "CentOS"'

- name: Debian
  include: debian.yml
  when: 'ansible_distribution == "Debian"'

- name: create /etc/docker directory
  file:
    path: /etc/docker
    state: directory
    mode: 0644

- name: copy logging driver configuration
  copy:
    src: files/daemon.json
    dest: /etc/docker/daemon.json
    mode: 0644
  notify: "restart Docker"

- name: enable docker service
  service:
    name: docker
    enabled: yes
    state: started

# Install docker-compose which also installs the docker python library required by some ansible docker modules
- name: install docker-compose
  pip:
    name: "docker-py"
    state: present

- name: check ssl_match_hostname
  stat:
    path: /usr/lib/python2.7/dist-packages/backports/ssl_match_hostname
  register: ssl_match_hostname_exists
  when: ansible_distribution == 'Debian'

- name: copy ssl_match_hostname
  copy:
    remote_src: yes
    src: /usr/local/lib/python2.7/dist-packages/backports/ssl_match_hostname
    dest: /usr/lib/python2.7/dist-packages/backports
  when: ansible_distribution == 'Debian' and not ssl_match_hostname_exists.stat.exists

---

- name: CentOS
  include: centos.yml
  when: 'ansible_distribution == "CentOS"'

- name: Debian
  include: debian.yml
  when: 'ansible_distribution == "Debian"'

- name: create /etc/docker directory
  file:
    path: /etc/docker
    state: directory
    mode: 0644

- name: copy logging driver configuration
  copy:
    src: files/daemon.json
    dest: /etc/docker/daemon.json
    mode: 0644
  notify: "restart Docker"

- name: enable docker service
  service:
    name: docker
    enabled: yes
    state: started

# Install docker-compose which also installs the docker python library required by some ansible docker modules
- name: install docker-compose
  pip:
    name: "docker-compose"
    state: present

Revert "switch to docker-py as docker-compose no longer working"
Revert "switch to docker-py as docker-compose no longer working"

This reverts commit c5d5759ccbe08e1e20c571fda34d4b1e21fe1eb6.
