Execution
Date 15 Sep 2024 07:41:52 +0100
Duration 00:00:01.17
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 plesk on host
  hosts: all
  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 message
  hosts: localhost
  connection: local
  vars_files:
    - zulip_vars.yml
  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 using apprise
          command: >
            apprise zulip://{{ bot_name }}@{{ zulip_url }}/{{ zulip_token }}/{{ zulip_topic }}
                    -t "Plesk Binary Status"
                    -b "Binary found on the following hosts: {{ plesk_found_on_hosts | join(', ') }}"