mariadb
mariadb copied to clipboard
Recipe not Converging under Centos7 and :create action on Server
:ghost: Brief Description
A recipe is not converging under Kitchen when the underlying OS is CentOS7 (works fine in CentOS6.9).
The recipe performs a simple install:
mariadb_server_install 'MariaDB Server install' do
version '10.4.10'
action [ :install, :create ]
end
The cookbook installs the correct version of MariaDB using the default :install action:
[root@database-01 ~]# mariadb --version
mariadb Ver 15.1 Distrib 10.4.10-MariaDB, for Linux (x86_64) using readline 5.1
But when the :create action is called, it fails on the Error executing action 'enable' on resource 'service[mysql]'
The reason for this is that the MariaDB service under CentOS7 is called mariadb
(not mysql
as in CentOS6)
[root@database-01 ~]# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
[root@database-01 ~]# systemctl status mysql
Unit mysql.service could not be found.
[root@database-01 ~]# systemctl status mariadb
● mariadb.service - MariaDB 10.4.10 database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled)
Drop-In: /etc/systemd/system/mariadb.service.d
└─migrated-from-my.cnf-settings.conf
Active: inactive (dead)
Docs: man:mysqld(8)
https://mariadb.com/kb/en/library/systemd/
It will also enable
and start
correctly when called manually:
[root@database-01 ~]# systemctl enable mariadb
Created symlink from /etc/systemd/system/mysql.service to /usr/lib/systemd/system/mariadb.service.
Created symlink from /etc/systemd/system/mysqld.service to /usr/lib/systemd/system/mariadb.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
[root@database-01 ~]# systemctl start mariadb
[root@database-01 ~]# systemctl status mariadb
● mariadb.service - MariaDB 10.4.10 database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
Drop-In: /etc/systemd/system/mariadb.service.d
└─migrated-from-my.cnf-settings.conf
Active: active (running) since Tue 2019-12-10 09:39:41 UTC; 4s ago
Docs: man:mysqld(8)
https://mariadb.com/kb/en/library/systemd/
Process: 15052 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
Process: 15007 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= || VAR=`/usr/bin/galera_recovery`; [ $? -eq 0 ] && systemctl set-environment _WSREP_START_POSITION=$VAR || exit 1 (code=exited, status=0/SUCCESS)
Process: 15005 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
Main PID: 15020 (mysqld)
Status: "Taking your SQL requests now..."
CGroup: /system.slice/mariadb.service
└─15020 /usr/sbin/mysqld
Dec 10 09:39:41 database-01.testkitchen.eagleeye.network mysqld[15020]: 2019-12-10 9:39:41 0 [Note] InnoDB: 10.4.10 started; log sequence numbe...id 21
Dec 10 09:39:41 database-01.testkitchen.eagleeye.network mysqld[15020]: 2019-12-10 9:39:41 0 [Note] InnoDB: Loading buffer pool(s) from /var/li..._pool
Dec 10 09:39:41 database-01.testkitchen.eagleeye.network mysqld[15020]: 2019-12-10 9:39:41 0 [Note] InnoDB: Buffer pool(s) load completed at 19...39:41
Dec 10 09:39:41 database-01.testkitchen.eagleeye.network mysqld[15020]: 2019-12-10 9:39:41 0 [Note] Plugin 'FEEDBACK' is disabled.
Dec 10 09:39:41 database-01.testkitchen.eagleeye.network mysqld[15020]: 2019-12-10 9:39:41 0 [Note] Server socket created on IP: '::'.
Dec 10 09:39:41 database-01.testkitchen.eagleeye.network mysqld[15020]: 2019-12-10 9:39:41 0 [Note] Reading of all Master_info entries succeeded
Dec 10 09:39:41 database-01.testkitchen.eagleeye.network mysqld[15020]: 2019-12-10 9:39:41 0 [Note] Added new Master_info '' to hash table
Dec 10 09:39:41 database-01.testkitchen.eagleeye.network mysqld[15020]: 2019-12-10 9:39:41 0 [Note] /usr/sbin/mysqld: ready for connections.
Dec 10 09:39:41 database-01.testkitchen.eagleeye.network mysqld[15020]: Version: '10.4.10-MariaDB' socket: '/var/lib/mysql/mysql.sock' port: 3...erver
Dec 10 09:39:41 database-01.testkitchen.eagleeye.network systemd[1]: Started MariaDB 10.4.10 database server.
:pancakes: Cookbook version
Cookbook Version: 3.1.0
:woman_cook: Chef-Infra Version
Chef Client version 14.14.29-1
:tophat: Platform details
OS Version: CentOS Linux release 7.6.1810 (Core)
Steps To Reproduce
Steps to reproduce the behaviour:
Create a database recipe as above, and kitchen converge a test machine under CentOS7. Kitchen file:
09:20 $ cat .kitchen.local.yml
---
driver:
name: vagrant
customize:
memory: 4096
cpus: 2
provisioner:
product_name: chef
product_version: 14.14.29
install_strategy: always
encrypted_data_bag_secret_key_path: "~/.chef/encrypted_data_bag_secret"
data_bags_path: "data_bags"
environments_path: "environments"
cookbooks_path: "cookbooks"
roles_path: "roles"
nodes_path: "test/nodes"
solo_rb:
environment: "am-qa"
attributes:
deploy_flag: true
testkitchen: true
customer: "test"
resolver:
nameservers: [
"1.1.1.1",
"8.8.8.8",
"8.8.4.4"
]
transport:
name: sftp
elevated: true
verifier:
name: inspec
sudo: true
platforms:
- name: centos-7
suites:
- name: database
run_list:
- role[database]
driver:
vm_hostname: database-01.testkitchen.eagleeye.network
network:
- ["forwarded_port", {guest: 3306, host: 3306}]
:police_car: Expected behavior
The converge to successfully complete and start the mariadb
service.
:heavy_plus_sign: Additional context
Believe the issue lies in the helper.rb file (186-188) where it is hardcoded to return the platform_service_name
as mysql
:
def platform_service_name(_version = node.run_state['mariadb']['version'])
'mysql'
end
This should by mariadb
for CentOS7 (not sure for other platforms), such as:
def platform_service_name
case node['platform_family']
when 'rhel'
'mariadb'
else
'mysql'
end
end
This is the specific error:
Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '1'
---- Begin output of /bin/systemctl --system enable mysql ----
STDOUT:
STDERR: Failed to execute operation: No such file or directory
---- End output of /bin/systemctl --system enable mysql ----
Ran /bin/systemctl --system enable mysql returned 1
This is the error trace from the converge: