- name: Install required Python modules
  pacman:
    name: python-requests
    state: present
  when: run_once_health_nginx is not defined

- name: "create {{ health_nginx_folder }}"
  file:
    path: "{{ health_nginx_folder }}"
    state: directory
    mode: 0755
  when: run_once_health_nginx is not defined

- name: create health-nginx.py
  template:
    src: health-nginx.py.j2
    dest: "{{ health_nginx_folder }}health-nginx.py"
  when: run_once_health_nginx is not defined

- name: create health-nginx.cymais.service
  template: 
    src: health-nginx.service.j2
    dest: /etc/systemd/system/health-nginx.cymais.service
  notify: reload health-nginx.cymais.service
  when: run_once_health_nginx is not defined

- name: set service_name to the name of the current role
  set_fact:
    service_name: "{{ role_name }}"
  when: run_once_health_nginx is not defined

- name: "include role for systemd-timer for {{service_name}}"
  include_role:
    name: systemd-timer
  vars:
    on_calendar:  "{{on_calendar_health_nginx}}"
  when: run_once_health_nginx is not defined

- name: run the health_nginx tasks once
  set_fact:
    run_once_health_nginx: true
  when: run_once_health_nginx is not defined

