Search code examples
postgresqlchef-infrainspec

regex function in chef inspec output


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

Solution

  • 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