- name: systemd daemon-reload
  systemd:
    daemon_reload: yes


# enable or disable 
- name: Enable & Restart jupyterhub
  systemd:
    name: "{{ item }}"
    enabled: yes
    state: restarted
  with_items:
    - jupyter
  when: jupyter_enabled

- name: Disable jupyterhub
  systemd:
    name: "{{ item }}"
    enabled: no
    state: stopped
  with_items:
    - jupyter
  when: not jupyter_enabled


- name: Put the nginx config file in place
  template:
    src: jupyter-nginx.conf
    dest: "{{ nginx_conf_dir }}/"
  when: jupyter_enabled

- name: Disable jupyterhub
  file:
    path: "{{ nginx_conf_dir }}/jupyter-nginx.conf"
    state: absent
  when: not jupyter_enabled

- name: Restart 'nginx' systemd service
  systemd:
    name: nginx
    state: restarted
