---
- name: Dependencies installed
  community.general.pkgng:
    name: py38-pip,py38-cryptography,py38-pillow,rust,libxslt,libxml2,py38-ldap,yarn,git-tiny,py38-cffi,py38-psycopg2,bash
    state: latest

- name: Source folder exists
  file:
    path: /usr/local/src
    owner: root
    mode: 0755
    state: directory

- name: Tandoor source @ master
  git:
    repo: "https://github.com/vabene1111/recipes.git"
    dest: /usr/local/src/tandoor
    update: yes
    force: yes

- name: Tandoor UI built
  shell:
    cmd: yarn install && yarn build
    chdir: /usr/local/src/tandoor/vue

- name: Tandoor migrations up to date
  command: bash -lc "direnv exec /usr/local/src/fifteen5 /usr/local/bin/python3.8 /usr/local/src/fifteen5/manage.py migrate"
  tags:
    - deploy

- name: Tandoor static files copied
  command: bash -lc "direnv exec /usr/local/src/fifteen5 /usr/local/bin/python3.8 /usr/local/src/fifteen5/manage.py collectstatic --noinput"
  tags:
    - deploy

- name: Tandoor js files copied
  command: bash -lc "direnv exec /usr/local/src/fifteen5 /usr/local/bin/python3.8 /usr/local/src/fifteen5/manage.py collectstatic_js_reverse"
  tags:
    - deploy

- name: Tandoor immortal file installed
  template:
    src: immortal.yml.j2
    dest: /usr/local/etc/immortal/tandoor.yml
    owner: root
    mode: 0644
  notify: Immortal restarted
