- name: /etc/sz-ds/env.conf
  tags: update-password
  template:
    src: etc/sz-ds/env.conf.j2
    dest: /etc/sz-ds/env.conf
    mode: a=r
  notify:
    - restart sz-ds
- name: /etc/systemd/system/sz-ds.service
  notify:
    - flyway migrate
    - restart sz-ds
  copy:
    src: etc/systemd/system/sz-ds.service
    dest: /etc/systemd/system/sz-ds.service

- name: git pull
  tags: sz-ds-pull
  notify:
    - flyway migrate
    - restart sz-ds
  register: git_pull
  git:
    repo: "https://{{ sz_ds_secrets.github.username }}:{{ sz_ds_secrets.github.password }}@github.com/SweetzpotAS/SweetzpotCentral"
    dest: /opt/sz-ds/src/SweetzpotCentral
    version: master

- name: Update GIT_REVISION
  tags: sz-ds-pull
  copy:
    dest: "/etc/sz-ds/env-git.conf"
    content: |
      GIT_REVISION={{ git_pull.after }}
- debug: msg=GIT_REVISION={{ git_pull.after }}

- name: sz-ds pip
  notify: restart sz-ds
  tags: sz-ds-pull
  pip:
    virtualenv: /opt/sz-ds/env
    virtualenv_python: python3
    chdir: /opt/sz-ds/src/SweetzpotCentral/data-server
    requirements: requirements.txt
    extra_args: --trusted-host github.com --process-dependency-links