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/plesk/tasks/main.yml

---
# tasks file for plesk

- name: Check if Plesk binary exists
  ansible.builtin.stat:
    path: /sbin/plesk
  register: plesk_binary

- name: Handle case when Plesk binary does not exist
  ansible.builtin.set_fact:
    plesk_found: false
  when: not plesk_binary.stat.exists

- name: Run Plesk command and capture full version text
  ansible.builtin.shell: |
    set -o pipefail
    /sbin/plesk -v | grep "Product version" | cut -d ":" -f2
  args:
    executable: /bin/bash
  register: plsk_out
  when: plesk_binary.stat.exists
  changed_when: false

- name: Check if 'Plesk' is in the output
  ansible.builtin.set_fact:
    plesk_found: "{{ 'Plesk' in plsk_out.stdout }}"
  when: plesk_binary.stat.exists

- name: Run Plesk command and capture numeric version only
  ansible.builtin.shell: |
    set -o pipefail
    /sbin/plesk -v | grep "Product version" | cut -d ":" -f2 | sed "s/^[ \t]*//" | awk '{print $NF}'
  args:
    executable: /bin/bash
  register: plsk_ver
  when: plesk_binary.stat.exists and plesk_found
  changed_when: false