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: Ensure MySQL service is running block: - name: Attempt to start MySQL service ansible.builtin.service: name: mysql state: started rescue: - name: Capture MySQL service status ansible.builtin.command: systemctl status mysql.service register: mysql_service_status changed_when: false - name: Debug MySQL service status ansible.builtin.debug: msg: "{{ mysql_service_status.stdout_lines }}" - name: Capture MySQL systemd logs ansible.builtin.shell: journalctl -xeu mysql.service | tail -n 20 register: mysql_systemd_logs changed_when: false - name: Output MySQL systemd logs ansible.builtin.debug: msg: "{{ mysql_systemd_logs.stdout_lines }}" - name: Fail gracefully with diagnostic information ansible.builtin.fail: msg: > MySQL service failed to start. See diagnostics: - Service Status: {{ mysql_service_status.stdout }} - Logs: {{ mysql_systemd_logs.stdout_lines }} - name: Check if MySQL data directory is initialized ansible.builtin.stat: path: /var/lib/mysql/mysql register: mysql_data_dir - name: Initialize MySQL data directory if missing ansible.builtin.command: mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql when: not mysql_data_dir.stat.exists - name: Verify MySQL port is listening ansible.builtin.wait_for: host: 127.0.0.1 port: 3306 timeout: 30 - name: Check MySQL error log ansible.builtin.shell: tail -n 20 /var/log/mysql/error.log register: mysql_error_log changed_when: false - name: Output MySQL error log ansible.builtin.debug: msg: "{{ mysql_error_log.stdout_lines }}"
Save
Regenerate Task Data
Back to List
Delete Task Definition
Loading...