有没有办法通过命令输出检查服务器上安装了哪些包?
describe command('mysql -e "select version();"') do
if its(:stdout) { should =~ /5.6.27-76.0-log/ }
describe package('MySQL-client') do
it { should be_installed }
else
describe package('Percona-client') do
it { should be_installed }
end
end
谢谢,
答案1
好吧,我找不到比这更好的办法了:
def mysql_version
command('mysql -e "select version();"').stdout
end
def plain_mysql?
mysql_version =~ /5.6.27-76.0-log/
end
def mysql_package_name
if plain_mysql?
'MySQL-client'
else
'Percona-client'
end
end
describe package(mysql_package_name) do
it { should be_installed }
end