regex function in chef inspec output

685 Views Asked by At

I am using chef inspec for the postgressql. I am executing the below command to match the output "local0". Because the output can be local0 or local1 etc. so given % to match any number value. but getting error. pls advise.

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

There are 1 best solutions below

0
On BEST ANSWER

you need to write a regular expression that matches your criteria.

the following might do the trick

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