Execution
Date 30 Aug 2024 10:45:39 +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
6 Files
0 Records

File: /home/ssh-gateway/ansible/compare_plesk_versions.yaml

---
- name: Playbook to compare plesk versions
  hosts: all
  gather_facts: true
  roles:
    - plesk
  vars:
    latest_ver: "18.0.63.3"
    installed_ver: "{{ plsk_ver.stdout }}"
    folder: /home/ssh-gateway/ansible/playbook_output
    inventory_file: /home/ssh-gateway/ansible/non_plesk_servers.ini
  tasks:
    - name: Add non-Plesk servers to inventory file
      when: not plesk_found
      ansible.builtin.lineinfile:
        path: "{{ inventory_file }}"
        line: "{{ ansible_facts.nodename }} ansible_port=2233 ansible_user=root"
        create: true
      delegate_to: localhost

    - name: Compare versions
      when: plesk_found and installed_ver is version(latest_ver, '==')
      ansible.builtin.debug:
        msg: "Installed version is the latest"
    - name: Check if update is needed
      when: plesk_found and installed_ver is version(latest_ver, '<')
      ansible.builtin.lineinfile:
        path: "{{ folder }}/versions_compare.txt"
        mode: '0644'
        create: true
        line: "{{ ansible_facts.nodename }} needs update because version installed is: {{ installed_ver }}"
      delegate_to: 127.0.0.1