---

- name: Install docker
  apt:
    pkg: "{{ item }}"
    state: installed
  with_items:
    - docker.io
    - docker-compose
  become: yes
  tags:
    - docker

- name: Create docker conf directory
  file:
    dest: /root/.docker
    state: directory
    recurse: true
    owner: root
    group: root
    mode: 700
  become: yes
  tags:
    - docker

- name: Set-up dockercfg
  template:
    src: dockercfg
    dest: /root/.docker/config.json
  become: yes
  tags:
    - docker

- name: Copy the clean script
  copy:
    src: docker_clean.sh
    dest: /usr/local/bin/docker_clean
    mode: 755
  become: yes
  tags:
    - docker

- name: Schedule the clean script
  cron:
    name: docker_clean
    minute: 0
    hour: 6
    job: /usr/local/bin/docker_clean
    user: root
    cron_file: ansible_docker_clean
  become: yes
  tags:
    - docker

---

- name: Install docker
  apt:
    pkg: "{{ item }}"
    state: installed
  with_items:
    - docker.io
    - docker-compose
  become: yes
  tags:
    - docker

- name: Create docker conf directory
  file:
    dest: /root/.docker
    state: directory
    recurse: true
    owner: root
    group: root
    mode: 700
  become: yes
  tags:
    - docker

- name: Set-up dockercfg
  template:
    src: dockercfg
    dest: /root/.docker/config.json
  become: yes
  tags:
    - docker

- name: Copy the clean script
  copy:
    src: docker_clean.sh
    dest: /usr/local/bin/docker_clean
    mode: 755
  become: yes
  tags:
    - docker

- name: Schedule the clean script
  cron:
    name: docker_clean
    minute: 0
    hour: 6
    job: /usr/local/bin/docker_clean
    user: root
    cron_file: ansible_docker_clean
  become: yes
  tags:
    - docker

- name: Add ansible user to docker group
  user:
    name: "{{ provisioning_user }}"
    groups: docker
    append: yes
  become: yes
  tags:
    - docker

Add ansible user to docker group
Add ansible user to docker group
