From 141f9334f25edeb999fe63bd7e56dfb1ebb32186 Mon Sep 17 00:00:00 2001 From: Micke Nordin Date: Fri, 4 Oct 2024 10:00:50 +0200 Subject: [PATCH] Add mysql command to host --- manifests/db_type.pp | 5 +++++ templates/mariadb/mysql.erb.sh | 4 ++++ 2 files changed, 9 insertions(+) create mode 100644 templates/mariadb/mysql.erb.sh diff --git a/manifests/db_type.pp b/manifests/db_type.pp index 295f839..440a3e9 100644 --- a/manifests/db_type.pp +++ b/manifests/db_type.pp @@ -90,6 +90,11 @@ define sunetdrive::db_type( ok_criteria => ['exit_status=0','max_age=2d'], warn_criteria => ['exit_status=1','max_age=3d'], } + file { '/usr/local/bin/mysql': + ensure => present, + content => template('sunetdrive/mariadb/mysql.erb.sh'), + mode => '0744', + } file { '/usr/local/bin/size-test': ensure => present, content => template('sunetdrive/mariadb/size-test.erb'), diff --git a/templates/mariadb/mysql.erb.sh b/templates/mariadb/mysql.erb.sh new file mode 100644 index 0000000..b62d38d --- /dev/null +++ b/templates/mariadb/mysql.erb.sh @@ -0,0 +1,4 @@ +#!/bin/bash +pw=$(yq -r '.services.db.environment[0]' /opt/mariadb/docker-compose.yml | awk -F '=' '{print $2}') + +docker exec -ti mariadb_db_1 mysql -u root -p"${pw}" -e "${@}"