Chef inspec 输出中的正则表达式函数

regex function in chef inspec output

我正在为 postgressql 使用 chef inspec。 我正在执行以下命令以匹配输出“local0”。因为输出可以是 local0 或 local1 等,所以给定 % 来匹配任何数值。但出现错误。请指教。

  describe command("sudo -u postgres psql postgres -c \"show syslog_facility;\"") do
    its("stdout") { should match ('local%') }
  end

您需要写一个符合您条件的regular expression

以下方法可能有效

describe command("sudo -u postgres psql postgres -c \"show syslog_facility;\"") do
  its("stdout") { should match /local(\d)*$/ }
end