---
- name: "docuum : set docker_max_image_space to {{ docker_max_image_space }}"
  lineinfile:
    path: /opt/docuum/docker_max_image_space
    state: present
    create: yes
    line: "{{ docker_max_image_space }}"
    regexp: ".*"  # replace previous content if changed

- name: "docuum : copy Dockerfile"
  copy:
    src: Dockerfile
    dest: /opt/docuum/
    mode: 0644

- name: "docuum : copy docuum.sh"
  copy:
    src: docuum.sh
    dest: /opt/docuum/
    mode: 0755

- name: "docuum : build container"
  shell: INITIAL_BUILD=1 /opt/docuum/docuum.sh

- name: "docuum : copy docuum.service"
  copy:
    src: docuum.service
    dest: /lib/systemd/system/docuum.service
  register: docuumservice

- name: "docuum : systemctl daemon-reload"
  systemd:
    daemon_reload: yes
  when: docuumservice is changed

- name: "docuum : ensure the systemd service is installed"
  systemd:
    name: docuum.service
    state: started
    enabled: yes
