Login
Default
Home
Containers
Host Nodes
Tasks
Definitions
Toggle theme
Light
Dark
Auto
Edit Task Definition
Task Name
Enter the name of the task.
Goal
Describe the goal you want to achieve, such as 'Install Nginx and start the service.'
Task Data (JSON)
- name: Stop MySQL service if running ansible.builtin.service: name: mysql state: stopped ignore_errors: true become: yes - name: Purge MySQL server packages ansible.builtin.apt: name: mysql-server state: absent purge: yes become: yes - name: Purge MySQL client packages ansible.builtin.apt: name: mysql-client state: absent purge: yes become: yes - name: Purge additional MySQL packages ansible.builtin.apt: name: "{{ item }}" state: absent purge: yes loop: - mysql-common - mysql-utilities ignore_errors: true become: yes - name: Purge all MySQL related packages found by dpkg ansible.builtin.shell: "dpkg --get-selections | grep -E 'mysql|mysql-server|mysql-client' | cut -f1" register: mysql_related_packages changed_when: false become: yes - name: Purge each MySQL related package found ansible.builtin.apt: name: "{{ item }}" state: absent purge: yes loop: "{{ mysql_related_packages.stdout_lines }}" when: mysql_related_packages.stdout_lines ignore_errors: true become: yes - name: Remove MySQL configuration and data directories ansible.builtin.file: path: "{{ item }}" state: absent loop: - /etc/mysql - /var/lib/mysql - /var/log/mysql ignore_errors: true become: yes - name: Check if leftover MySQL configuration directory exists ansible.builtin.stat: path: /etc/mysql register: mysql_config_check become: yes - name: Remove leftover MySQL configuration directory if it exists ansible.builtin.file: path: /etc/mysql state: absent when: mysql_config_check.stat.exists become: yes - name: Clean up orphaned packages after MySQL removal ansible.builtin.apt: autoclean: yes autoremove: yes become: yes - name: Reboot the system if required ansible.builtin.reboot: msg: "Reboot initiated by playbook post-MySQL removal" connect_timeout: 5 reboot_timeout: 600 when: ansible_facts['os_family'] == 'Debian' become: yes
Save
Regenerate Task Data
Back to List
Delete Task Definition
Loading...