Execution
Date 15 Sep 2024 07:28:25 +0100
Duration 00:00:01.57
Controller ssh-gw-4.layershift.com
User root
Versions
Ansible 2.16.11
ara 1.7.2 / 1.7.2
Python 3.10.10
Summary
1 Hosts
2 Tasks
2 Results
2 Plays
1 Files
0 Records

File: /home/ssh-gateway/ansible/kuly/test_zulip.yaml

---
- name: Test zulip
  hosts: all
  gather_facts: false
  tasks:
    - name: Check if the binary exists on the remote host
      test_z:
        binary_path: "/sbin/plesk"
      register: plesk_check_result
    - name: Aggregate binary check results
      set_fact:
        plesk_found_on_hosts: "{{ plesk_found_on_hosts | default([]) + [inventory_hostname] }}"
      when: plesk_check_result.binary_exists | bool
- name: Send the messaage
  hosts: localhost
  tasks:
    - name: Send notification to Zulip if binary exists on any remote host
      when: plesk_found_on_hosts is defined and plesk_found_on_hosts | length > 0
      block:
        - name: Notify about the found binary
          command: >
            apprise -t "Plesk Binary Status"
                    -b "Binary found on the following hosts: {{ plesk_found_on_hosts | join(', ') }}"
                    zulip://{{ zulip_token }}@{{ zulip_url }}/{{ zulip_channel }}
          vars:
            zulip_url: "layershift.zulipchat.com"
            zulip_token: "VZzGBE3toQNvFw3Fp6L6L1beR9j6nJIN"
            zulip_channel: "tutorial-kuly"
            zulip_topic: "Server Notifications"