Execution
Date 08 Apr 2025 09:19:16 +0100
Duration 00:03:20.16
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
395 Hosts
4 Tasks
1549 Results
1 Plays
1 Files
0 Records

File: /home/ssh-gateway/ansible/kuly/RM9972-2.yaml

---
- name: Playbook to check
  hosts: all
  gather_facts: false
  vars:
    sqlite_command: "sqlite3 /usr/local/psa/var/modules/monitoring/monitoring.sqlite3 \"select * from params where name = 'cloud_service_api_key'\""
    api_key_to_check: "15c642d7e43747cbe4d1f8062d8747e547c111d0aaa3c229e68f1179a61fbcaa"
    found_file: "/home/ssh-gateway/ansible/kuly/RM9972-2-found.txt"
  tasks:
    - name: Gather info
      plesk_info:
      register: plsk
    - name: Run command on plesk server
      when: plsk.plesk_found
      ansible.builtin.shell: |
        set -o pipefail
        hostname -f
        if {{ sqlite_command }} | grep -q {{ api_key_to_check }}; then
        echo "FOUND!!!!!";
        else
        echo "NOT found in database.";
        fi;
        agent360 --info | grep "Server:" | awk '{ print $2 }'
      args:
        executable: /bin/bash
      register: result
      changed_when: false
      failed_when: false
    - name: Check for the specific string and display if not found
      ansible.builtin.debug:
        var: result.stdout_lines
    - name: Save found ones to file
      when: result.stdout | regex_search('FOUND')
      ansible.builtin.lineinfile:
        path: "{{ found_file }}"
        line: "{{ inventory_hostname }}"
        create: true
        mode: '0644'
      delegate_to: 127.0.0.1