diff --git a/roles/database/tasks/main.yml b/roles/database/tasks/main.yml index a20177c..ffcf59e 100644 --- a/roles/database/tasks/main.yml +++ b/roles/database/tasks/main.yml @@ -47,6 +47,16 @@ - name: Flush handlers (reinicia MySQL abans de crear usuaris) ansible.builtin.meta: flush_handlers +# ✅ Fix Ubuntu 24.04: canviar auth_socket per mysql_native_password +- name: Canviar autenticació de root a mysql_native_password + ansible.builtin.shell: | + mysql -u root -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '{{ db_root_password }}';" + mysql -u root -e "FLUSH PRIVILEGES;" + args: + executable: /bin/bash + become: yes + ignore_errors: yes + # ✅ Crear /root/.my.cnf perquè community.mysql pugui autenticar-se - name: Crear /root/.my.cnf amb credencials de root ansible.builtin.copy: diff --git a/roles/database/templates/my.cnf.j2 b/roles/database/templates/my.cnf.j2 new file mode 100644 index 0000000..2d82bd3 --- /dev/null +++ b/roles/database/templates/my.cnf.j2 @@ -0,0 +1,3 @@ +[client] +user=root +password={{ db_root_password }} \ No newline at end of file