- name: start supervisor
  systemd:
    name: supervisor
    state: started

# 2022-12-21: python_version determined by scripts/local_facts.fact -- to match templates/lokole-nginx.conf.j2
- name: Create Lokole admin user with password, for http://box{{ lokole_url }}    # http://box/lokole
  shell: |
    while read envvar; do export "$envvar"; done < {{ lokole_run_dir }}/settings.env
    cd {{ lokole_venv }}/lib/python{{ python_version }}/site-packages/
    export FLASK_APP="opwen_email_client.webapp:app"
    {{ lokole_venv }}/bin/flask manage createadmin --name='{{ lokole_admin_user }}' --password='{{ lokole_admin_password }}'

- name: Change owner of dbfiles
  file:
    path: "{{ item.path }}"
    state: file
    owner: "{{ lokole_user }}"
    group: "{{ lokole_user }}"
    mode: u=rw
  loop:
    - { path: "{{ lokole_run_dir }}/users.sqlite3" }
#    - { path: "{{ lokole_run_dir }}/celery.sqlite3" }
