Execution
Date 18 Feb 2026 09:28:22 +0000
Duration 00:00:04.72
Controller ssh-gw-4.layershift.com
User root
Versions
Ansible 2.16.11
ara 1.7.4 / 1.7.4
Python 3.10.10
Summary
0 Hosts
1 Tasks
0 Results
1 Plays
1 Files
0 Records

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

---
- name: Check watchdog for amavis entries
  hosts: all
  gather_facts: false
  tasks:
    - name: Get server info
      plesk_info:
      register: plsk
    - name: Execute checks when plesk PES found
      when:
        - plsk.plesk_found
        - "'email-security' in (plsk.plesk_extensions | map(attribute='id') | list)"
      block:
        - name: Run query
          ansible.builtin.shell: |
            set -o pipefail
            /usr/bin/sqlite3 /usr/local/psa/var/modules/watchdog/watchdog.sqlite3 "select * from module_watchdog_service where name='amavisd'"
          args:
            executable: /bin/bash
          changed_when: false
          register: query_res
        - name: Check template
          ansible.builtin.stat:
            path: /usr/local/psa/var/modules/watchdog/etc/service.tpl.d/amavisd
          register: amavisd_template
          changed_when: false
        - name: Check if amavisd is active
          ansible.builtin.stat:
            path: /usr/local/psa/var/modules/watchdog/etc/service.d/amavisd
          register: amavisd_active
          changed_when: false
        - name: Report amavisd watchdog problems
          ansible.builtin.debug:
            msg: |
              Amavisd watchdog configuration problems detected:
              - DB entry: {{ 'MISSING' if query_res.stdout | length == 0 else 'OK' }}
              - Template file: {{ 'MISSING' if not amavisd_template.stat.exists else 'OK' }}
              - Active service file: {{ 'MISSING' if not amavisd_active.stat.exists else 'OK' }}
          when: >
            query_res.stdout | length == 0 or
            not amavisd_template.stat.exists or
            not amavisd_active.stat.exists
          changed_when: true
        - name: Save to file
          ansible.builtin.lineinfile:
            path: test.txt
            create: true
            mode: '0644'
            line: |
              Host: {{ inventory_hostname }}
                #              DB entry: {{ 'MISSING' if query_res.stdout | length == 0 else 'OK' }}
                #Template file: {{ 'MISSING' if not amavisd_template.stat.exists else 'OK' }}
                #Active service file: {{ 'MISSING' if not amavisd_active.stat.exists else 'OK' }}
          delegate_to: 127.0.0.1