Execution
Date 23 May 2025 07:47:46 +0100
Duration 00:00:02.59
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
2 Hosts
3 Tasks
3 Results
1 Plays
1 Files
0 Records

File: /home/ssh-gateway/ansible/kuly/RM10051-get-affected-servers.yaml

---
- name: Playbook to create a list of affected servers
  hosts: all
  gather_facts: false
  vars:
    ini_file: /usr/local/psa/admin/conf/panel.ini
    save_file: /home/ssh-gateway/ansible/kuly/RM10051-get-affected-servers.txt
    section: "settings.general"
    directive: 'short_open_tag.values[]="on"'
  tasks:
    - name: Get server info
      plesk_info:
      register: pl
    - name: Run grep command
      when: pl.plesk_found
      ansible.builtin.shell: |
        set -o pipefail
        awk '
        $0 ~ /^\[{{ section }}\]/ { in_section=1; next }
        $0 ~ /^\[/ && $0 !~ /^\[{{ section }}\]/ { in_section=0 }
        in_section && $0 ~ /^{{ directive | regex_escape }}/ { found=1 }
        END { exit !found }
        ' "{{ ini_file }}"
      args:
        executable: /bin/bash
      register: directive_check
      changed_when: false
      failed_when: false
    - name: Save hostname if directive is missing
      when: directive_check.rc != 0
      ansible.builtin.lineinfile:
        path: "{{ save_file }}"
        line: "{{ inventory_hostname }}"
        create: true
        mode: '0644'
        state: present
      delegate_to: 127.0.0.1