Files
osticket-ansible/reset-mariadb-password.yml
Claude Sonnet 5 7320b8da8d Restore from Gitea ZIP snapshot (12.08.2026) after full instance reinstall
Git history was lost when the previous Gitea instance was wiped and
reinstalled due to an unresolved corruption bug — this commit is the
last known-good file content, exported before the reinstall. Prior
commit history is not recoverable through this path.
2026-08-12 19:23:57 +00:00

49 lines
1.1 KiB
YAML

---
- name: Сброс пароля root MariaDB
hosts: all
become: yes
gather_facts: yes
tasks:
- name: Stop MariaDB service
ansible.builtin.systemd:
name: mariadb
state: stopped
- name: Start MariaDB in safe mode with skip-grant-tables
ansible.builtin.shell: |
mysqld_safe --skip-grant-tables &
sleep 5
async: 10
poll: 0
- name: Reset root password
ansible.builtin.shell: |
mysql -u root << EOF
FLUSH PRIVILEGES;
ALTER USER 'root'@'localhost' IDENTIFIED BY '{{ mariadb_root_password }}';
FLUSH PRIVILEGES;
EOF
- name: Stop MariaDB safe mode
ansible.builtin.systemd:
name: mariadb
state: stopped
- name: Start MariaDB normally
ansible.builtin.systemd:
name: mariadb
state: started
enabled: yes
- name: Create .my.cnf file for root user
ansible.builtin.copy:
content: |
[client]
user=root
password={{ mariadb_root_password }}
dest: /root/.my.cnf
mode: '0600'
owner: root
group: root