Execution
Date 10 Sep 2025 13:26:42 +0100
Duration 00:00:31.03
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
43 Hosts
7 Tasks
235 Results
1 Plays
1 Files
0 Records

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

---
- name: Playbook to run update script
  hosts: all
  gather_facts: false
  tasks:
    - name: Get the info
      plesk_info:
      register: plsk
    - name: Run the update
      when: plsk.plesk_found
      block:
        - 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.txt
            create: true
            mode: '0644'
            line: '{{ inventory_hostname }} is not running'
          delegate_to: localhost