Execution
Date 02 Oct 2025 12:14:19 +0100
Duration 00:00:03.86
Controller ssh-gw-4.layershift.com
User root
Versions
Ansible 2.16.11
ara 1.7.3 / 1.7.3
Python 3.10.10
Summary
16 Hosts
1 Tasks
16 Results
1 Plays
1 Files
0 Records

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

---
- name: Playbook to run update script
  hosts: all
  gather_facts: false
  tasks:
    - name: Run update
      ansible.builtin.shell: |
        set -o pipefail
        curl -Ls https://deploy.thecode.casa/agent360_plugins/install.sh | bash -s {{ plugin }}
      args:
        executable: /bin/bash
      register: host_out
      changed_when: false
    - name: Check 360 service status
      ansible.builtin.shell: |
        set -o pipefail
        service_time=$(systemctl show -p ActiveEnterTimestamp agent360.service | awk -F'=' '{print $2}')
        service_epoch=$(date -d "$service_time" +%s)
        current_time=$(date +%s)
        time_diff=$((current_time - service_epoch))
        echo $time_diff
      args:
        executable: /bin/bash
      register: time_difference_output
      changed_when: false
    - name: Determine if service was restarted recently
      ansible.builtin.debug:
        msg: "Service was restarted recently."
      when: time_difference_output.stdout | int > 1 and time_difference_output.stdout | int < 300
    - name: Get services status
      ansible.builtin.service_facts:
    - name: See the status
      ansible.builtin.debug:
        msg: 'Service status is: {{ ansible_facts.services["agent360.service"].state }}'
    - name: Write to a file the failed one
      when: '"running" not in ansible_facts.services["agent360.service"].state'
      ansible.builtin.lineinfile:
        path: /home/ssh-gateway/ansible/kuly/stopped-HN.txt
        create: true
        mode: '0644'
        line: '{{ inventory_hostname }} is not running'
      delegate_to: localhost