Execution
Date 28 May 2025 10:06:50 +0100
Duration 00:00:09.83
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
0 Hosts
1 Tasks
0 Results
1 Plays
1 Files
0 Records

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

---
- name: Check if there is a need to upgrade agent360
  hosts: all
  gather_facts: false
  tasks:
    - name: Get the latest version of agent360 from GitHub
      ansible.builtin.shell: |
        latest=$(curl -sL https://api.github.com/repos/plesk/agent360/releases/latest | jq -r ".tag_name" | sed 's/^v//')
        echo $latest
      register: latest_version_out
      changed_when: false
      run_once: true

    - name: Set the latest_version variable
      set_fact:
        latest_version: "{{ latest_version_out.stdout }}"
      run_once: true

    - name: Get installed version and compare
      ansible.builtin.shell: |
        set -o pipefail
        pip$(head -1  $(which agent360)| awk -F "python" '{print $2}') show agent360 | grep Version | awk '{ print $2 }'
      args:
        executable: /bin/bash
      register: ver_out
      changed_when: ver_out.rc != 0

    - name: Log the ones need updating
      when: ver_out.rc == 0 and ver_out.stdout < latest_version
      ansible.builtin.lineinfile:
        path: /home/ssh-gateway/ansible/kuly/agent360_need_upgrade.txt
        create: true
        mode: '0644'
        line: '{{ inventory_hostname }} need upgrade - version {{ ver_out.stdout }}'
      delegate_to: localhost