---
- name: Dependencies installed
  community.general.pkgng:
    name: py39-pip py39-cryptography py39-ldap3 py39-pillow rust libxslt libxml2 yarn git-tiny py39-cffi py39-psycopg2
    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/TandoorRecipes/recipes.git"
    dest: /usr/local/src/tandoor
    update: yes
    force: yes
  tags:
    - update

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

- name: Tandoor env file installed
  template:
    src: envrc.j2
    dest: /usr/local/src/tandoor/.env
    owner: root
    mode: 0644

- name: Libraries for ldap linked
  file: src=/usr/local/include/lber.h dest=/usr/include/lber.h state=link

- name: Libraries for ldap linked
  file: src=/usr/local/include/lber_types.h dest=/usr/include/lber_types.h state=link

- name: Libraries for ldap linked
  file: src=/usr/local/include/ldap_cdefs.h dest=/usr/include/ldap_cdefs.h state=link

- name: Libraries for ldap linked
  file: src=/usr/local/include/ldap_features.h dest=/usr/include/ldap_features.h state=link

- name: Libraries for ldap linked
  file: src=/usr/local/include/ldap.h dest=/usr/include/ldap.h state=link

- name: Libraries for ldap linked
  file: src=/usr/local/include/openldap.h dest=/usr/include/openldap.h state=link

- name: Libraries for sasl linked
  file: src=/usr/local/include/sasl dest=/usr/include/sasl state=link


- name: Tandoor requirements up to date
  pip:
    requirements: /usr/local/src/tandoor/requirements.txt
    executable: pip
  tags:
    - update


- name: Tandoor migrations up to date
  command: python3.9 /usr/local/src/tandoor/manage.py migrate

- name: Tandoor static files copied
  command: python3.9 /usr/local/src/tandoor/manage.py collectstatic --noinput

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