Execution
Date 28 Jun 2024 08:56:13 +0100
Duration 00:00:07.48
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
4 Tasks
4 Results
1 Plays
1 Files
0 Records

File: /home/ssh-gateway/ansible/projects/RM9615/RM9615-remove_duplicate_mysql_settings.yaml

---
- name: Run a script that checks and removes mysql duplicate settings
  hosts: all,!versatile-chipmunk.man-1.vm.plesk-server.com
  gather_facts: false
  vars:
    folder: /home/ssh-gateway/ansible/projects/RM9615
    files_to_upload:
      - "{{ folder }}/RM9615-list_directives"
      - "{{ folder }}/remove_mysql_settings.sh"
  tasks:
    - name: Check if /etc/my.cnf exists
      ansible.builtin.stat:
        path: /etc/my.cnf
      register: my_cnf

    - name: Check if /etc/my.cnf.d/zz_layershift-defaults.cnf exists
      ansible.builtin.stat:
        path: /etc/my.cnf.d/zz_layershift-defaults.cnf
      register: layershift_defaults_cnf

    - name: Upload script if both files exist
      ansible.builtin.copy:
        src: "{{ item }}"
        dest: "/tmp/{{ item | basename }}"
        mode: '0755'
      with_items: "{{ files_to_upload }}"
      when: my_cnf.stat.exists and layershift_defaults_cnf.stat.exists

    - name: Run the script if both files exist
      when: my_cnf.stat.exists and layershift_defaults_cnf.stat.exists
      ansible.builtin.shell: |
        set -o pipefail
        chmod 755 /tmp/remove_mysql_settings.sh
        /tmp/remove_mysql_settings.sh
      args:
        executable: /bin/bash
      changed_when: true