---

- name: Check mageia-docker mandatory packages installed
  urpmi: name={{ item.pkg }} state=installed update_cache=yes no-recommends=yes
  with_items: 
    - { pkg: git }
    - { pkg: project-builder }

- name: Install git mageia-docker repo
  ## Problem as run as root
  #git: repo=git@github.com:bcornec/mageia-docker.git dest=/home/bruno/mageia-docker force=yes accept_hostkey=yes
  command: su - bruno -c "rm -rf /home/bruno/mageia-docker ; git clone git@github.com:bcornec/mageia-docker.git /home/bruno/mageia-docker"

- name: Check ownership for git repo
  file: path=/home/bruno/mageia-docker owner=bruno group=bruno recurse=true

- name: Install mageia-docker conf file
  copy: src=/users/bruno/prj/musique-ancienne.org/mondorescue.org/.mageia-docker dest=/home/bruno/.mageia-docker owner=bruno group=bruno mode=0644 backup=yes

- name: Set up mageia-docker crontab
  cron: name=mageia-docker-{{ item.v }} minute=43 hour={{ item.t }} job='/home/bruno/mageia-docker/mageia-docker -v {{ item.v }} -m {{ urpmi_server }}' user=bruno state=present backup=yes
  with_items: 
    - { v: 5 , t: 00 }
    - { v: cauldron, t: 01 }

- name: Set up docker cleanup crontab
  cron: name=docker-cleanup minute=43 hour=07 job='docker image prune -f' user=bruno state=present backup=yes
