geerlingguy / ansible-role-mysql

Ansible Role - MySQL
https://galaxy.ansible.com/geerlingguy/mysql/
MIT License
1.05k stars 866 forks source link

mariadb root password not applied on setup #460

Closed ahrib closed 2 years ago

ahrib commented 3 years ago

Gday, firstly thanks for providing such useful things to the community.

Using Ubuntu 20.04 LTS and attempting to install mariadb on a clean docker image. The root password is never set and this prevents the mysql service stopping or restarting (e.g. service mysqk stop) and the playbook does not complete initial setup as expected.

I suspect the version check on this line needs a massage https://github.com/geerlingguy/ansible-role-mysql/blob/57c8638cc5e0659165c5e6b8c2f0f60884e29b46/tasks/secure-installation.yml#L50

output of mysql --version (with mariadb-server installed)

mysql  Ver 15.1 Distrib 10.3.31-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2

playbook

- name: configure db 
  hosts: db
  roles:
    - role: geerlingguy.mysql
      become: yes 
      vars:
        mysql_packages:
          - mariadb-server
          - mariadb-client
          - mariadb-common
          - mariadb-backup
          - python3-mysqldb  # req for ansible
        # mysql root user
        mysql_root_username: root
        mysql_root_password: supersecurepassword
        mysql_root_password_update: true

dockerfile used for local test environment

ARG UBUNTU_VERSION
FROM ubuntu:20.04

ARG SSH_USER='ansible'
ARG SSH_PASS='ansible'

# required unattended install of tzdata package (ssh dep)
ARG DEBIAN_FRONTEND=noninteractive
ARG DEBCONF_NONINTERACTIVE_SEEN=true
ARG TZ_AREA=Etc
ARG TZ_ZONE=UTC

RUN echo tzdata tzdata/Areas select ${TZ_AREA} | debconf-set-selections; \
    echo tzdata tzdata/Zones/${TZ_AREA} select ${TZ_ZONE} | debconf-set-selections;

# minimim deps
RUN apt-get update \ 
    && apt-get upgrade -y \ 
    && apt-get install -y iputils-ping curl nano wget ssh sudo

# a user
RUN useradd -m -s /bin/bash ${SSH_USER} -p "$(openssl passwd -1 ${SSH_PASS})"
RUN usermod -aG sudo ${SSH_USER}

# hack "tail -f /dev/null" keeps docker running after service commands
CMD service ssh start && tail -f /dev/null

To help any others here is a workaround I have found to avoid service issues / cnf file issues. Specify a blank root password by adding the following to the play

vars:
  mysql_root_password:
stale[bot] commented 2 years ago

This issue has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution!

Please read this blog post to see the reasons why I mark issues as stale.

stale[bot] commented 2 years ago

This issue has been closed due to inactivity. If you feel this is in error, please reopen the issue or file a new issue with the relevant details.