我有以下类,它安装 mysql 并设置一个名为 user 的用户,但是当 create-database 命令运行时,尚未创建用户。我如何链接命令以便在 create-database 尝试使用它之前创建用户?
class { '::mysql::server':
package_name => 'mariadb-server.x86_64',
root_password => 'root',
remove_default_accounts => true,
override_options => $override_options,
restart => true,
users => {
'user@%' => {
ensure => 'present',
max_connections_per_hour => '0',
max_queries_per_hour => '0',
max_updates_per_hour => '0',
max_user_connections => '0',
password_hash => '...',
}
},
grants => {
'user@%/*.*' => {
ensure => 'present',
options => ['GRANT'],
privileges => ['ALL'],
table => '*.*',
user => 'user@%',
},
}
}->
exec { 'create-database':
creates => '/opt/dbinstalled',
command => '/usr/bin/mysql -u user -puser < /create-db.sql'
}
我正在使用 puppetlabs-mysql 包来安装 mysql。