Execution
Date 13 Sep 2024 10:03:21 +0100
Duration 00:00:02.97
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
1 Hosts
4 Tasks
4 Results
1 Plays
6 Files
0 Records

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

---
- name: Remove specific monitoring blocks
  hosts: all
  gather_facts: true
  roles:
    - plesk
  tasks:
    - name: Run if plesk server
      when: plesk_found
      block:
        - name: Backup /etc/agent360-custom.ini with a timestamp
          ansible.builtin.copy:
            src: /etc/agent360-custom.ini
            dest: "/etc/agent360-custom.ini.bak_{{ ansible_date_time.epoch }}"
            mode: '0644'
            remote_src: true
        - name: Read the /etc/agent360-custom.ini file
          ansible.builtin.slurp:
            path: /etc/agent360-custom.ini
            register: agent_ini_file
        - name: Remove php_errors_monitoring block
          ansible.builtin.replace:
            path: /etc/agent360-custom.ini
            regexp: '(\[php_errors_monitoring\](?:\n(?!\[)[^\n]+)+)'
            replace: ''
          when: "'[php_errors_monitoring]' in agent_ini_file.content | b64decode"
        - name: Remove apache_error_monitoring block
          ansible.builtin.replace:
            path: /etc/agent360-custom.ini
            regexp: '(\[apache_error_monitoring\](?:\n(?!\[)[^\n]+)+)'
            replace: ''
          when: "'[apache_error_monitoring]' in agent_ini_file.content | b64decode"