Execution
Date 04 Sep 2024 15:49:34 +0100
Duration None
Controller ssh-gw-4.layershift.com
User root
Versions
Ansible 2.16.4
ara 1.7.1 / 1.7.1
Python 3.10.10
Summary
0 Hosts
1 Tasks
0 Results
1 Plays
11 Files
0 Records

File: /home/ssh-gateway/ansible/roles/imunify360/tasks/main.yml

---
# tasks file for imunify360-agent
- name: Check if imunify360-agent binary exists
  ansible.builtin.stat:
    path: /usr/bin/imunify360-agent
  register: imunify_binary

- name: Handle case when imunify360-agent binary does not exist
  ansible.builtin.set_fact:
    imunify_found: false
  when: not imunify_binary.stat.exists

- name: Run imunify360-agent health command and capture the output
  ansible.builtin.shell: |
    set -o pipefail
    /usr/bin/imunify360-agent health
  args:
    executable: /bin/bash
  register: imunify_health_out
  when: imunify_binary.stat.exists
  changed_when: false

- name: Check if 'OK' is in the imunify360-agent health output
  ansible.builtin.set_fact:
    imunify_found: "{{ 'OK' in imunify_health_out.stdout }}"
  when: imunify_binary.stat.exists

- name: Run imunify360-agent health with --json flag and capture output
  ansible.builtin.shell: |
    set -o pipefail
    /usr/bin/imunify360-agent health --json
  args:
    executable: /bin/bash
  register: imunify_health_json
  when: imunify_binary.stat.exists and imunify_found
  changed_when: false