--- - name: Prepare hosts: all gather_facts: false tasks: - name: Install python for Ansible raw: test -e /usr/bin/python3 || (apt -y update && apt install -y python3-minimal) become: true changed_when: false - hosts: all become: true tasks: - name: Update all caches to avoid errors due to missing remote archives apt: update_cache: true changed_when: false - hosts: deprecated become: true tasks: - name: Install MariaDB apt: name: - mariadb-client - mariadb-server - python3-pymysql state: present - name: Enable and start MariaDB service: name: mysql state: started enabled: true - name: Deploy username and password for the root database user copy: src: "deprecated-root-my.cnf" dest: "/root/.my.cnf" owner: root group: root mode: 0400 - name: Set password for the root database user (creating separate entry for different hosts) mysql_user: check_implicit_admin: true name: root host: "{{ item }}" password: "root_password" login_unix_socket: "/var/run/mysqld/mysqld.sock" with_items: - "localhost" - "127.0.0.1" - "::1" - "{{ ansible_hostname }}" - name: Disable use of unix socket login command: "mysql -B -e \"update mysql.user set plugin='' where user='root' and plugin='unix_socket'; flush privileges;\"" - name: Create Debian system maintenance user mysql_user: name: debian-sys-maint password: debian-sys-maint-password login_unix_socket: "/var/run/mysqld/mysqld.sock" - name: Deploy Debian system maintenance user login configuration copy: src: "deprecated-debian.cnf" dest: "/etc/mysql/debian.cnf" owner: root group: root mode: 0600