---
- name: install docker
  sudo: yes
  yum:
    name: docker
    state: latest

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

- name: add {{ ansible_ssh_user }} to docker group
  sudo: yes
  user:
    name: "{{ ansible_ssh_user }}"
    groups: docker
    append: yes

# required to install pip
- name: install epel-release
  sudo: yes
  yum:
    name: epel-release
    state: present

# required to install docker-py with pip
- name: install python-pip
  sudo: yes
  yum:
    name: python-pip
    state: present

# required for ansible docker module
- name: install docker-py
  sudo: yes
  pip:
    name: docker-py
    # docker-py 0.4.0 works with ansible 1.8.2
    version: 0.4.0
    state: present

---
- name: install docker
  sudo: yes
  yum:
    name: docker
    state: latest

- name: docker consul dns
  sudo: yes
  lineinfile:
    dest: /etc/sysconfig/docker 
    state: present
    regexp: ^OPTIONS
    line: OPTIONS=--selinux-enabled -H fd:// --dns {{ ansible_eth0.ipv4.address }}  --dns-search service.consul

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

- name: add {{ ansible_ssh_user }} to docker group
  sudo: yes
  user:
    name: "{{ ansible_ssh_user }}"
    groups: docker
    append: yes

# required to install pip
- name: install epel-release
  sudo: yes
  yum:
    name: epel-release
    state: present

# required to install docker-py with pip
- name: install python-pip
  sudo: yes
  yum:
    name: python-pip
    state: present

# required for ansible docker module
- name: install docker-py
  sudo: yes
  pip:
    name: docker-py
    # docker-py 0.4.0 works with ansible 1.8.2
    version: 0.4.0
    state: present

Add localhost dns lookup for the docker daemon.
Add localhost dns lookup for the docker daemon.
