- become: true
  hosts: all
  name: Restart monitoring service
  tasks:
  - name: Stop prezenta service
    systemd:
      name: prezenta.service
      state: stopped
  - name: Wait for service to stop
    wait_for:
      timeout: 10
  - name: Start prezenta service
    systemd:
      enabled: true
      name: prezenta.service
      state: started
  - name: Verify service is running
    register: service_status
    systemd:
      name: prezenta.service
  - name: Report service restart
    uri:
      body:
        device_ip: '{{ ansible_host }}'
        hostname: '{{ inventory_hostname }}'
        service_status: '{{ service_status.status.ActiveState }}'
      body_format: json
      method: POST
      url: http://{{ ansible_controller_ip }}/api/service_restarted
