Execution
Date 30 Aug 2024 08:13:20 +0100
Duration 00:00:03.94
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
1 Hosts
10 Tasks
10 Results
1 Plays
6 Files
0 Records

File: /home/ssh-gateway/ansible/projects/RM9718/RM9718-cron-install.yaml

---
- name: Playbook to install the crons
  hosts: all
  gather_facts: false
  roles:
    - plesk
  tasks:
    - name: On plesk server do this
      ansible.builtin.shell: |
        set -o pipefail
        imunify360-agent version
      args:
        executable: /bin/bash
      register: imun_out
      failed_when: imun_out.rc != 0 and "command not found" not in imun_out.stderr
      changed_when: false
      ignore_errors: true

    - name: Print it
      ansible.builtin.debug:
        var: imun_out

    - name: If imunify is installed
      when: imun_out.stdout is match('^\\d+\\.\\d+\\.\\d+')
      block:
        - name: Upload the script
          ansible.builtin.slurp:
            src: /home/ssh-gateway/ansible/projects/RM9718/setup_random_cron.sh
          delegate_to: 127.0.0.1
          register: file_contents

        - name: Execute the script
          ansible.builtin.shell: |
            set -o pipefail
            echo -e "{{ file_contents.content }}" | base64 -d > /tmp/setup_random_cron.sh
            chmod 755 /tmp/setup_random_cron.sh
            /tmp/setup_random_cron.sh
          args:
            executable: /bin/bash
          register: updates_out
          changed_when: false

    - name: Print error message when imunify360-agent is not found
      when: imun_out.rc == 127 or "command not found" in imun_out.stderr
      ansible.builtin.debug:
        msg: "Error: imunify360-agent command not found, skipping the rest of the steps..."