I think you want --datadir=${mariadb_data_dir}. Also, why change the message to read "Failed to create mysqldb" if you are trying to install MariaDB?