0

Im new to Chef /Inspec test writing. What Im trying to do is validate a host name/IP address within a file and match it to what is in DNS. If the IP address in file doesnt match what is in DNS, the test should fail.

example

describe host('example.com') do
  it { should be_resolvable }
  its('ipaddress') { should include '12.34.56.78' }
  its('stdout') { should match 'ipaddress' }
end

the 'example.com' would be a $variable that comes from within a file

the ''12.34.56.78' would also be a $variable that comes from within a file however should match what is in DNS

Is this even possible to do? do I need to or can I use a bash script within the inspec file that has some awk commands?

describe bash('filename.sh') do
  it { should be_resolvable }
  its('stdout') { should match 'ipaddress' }
  its('stderr') { should eq '' }
  its('ipaddress') { should include '12.34.56.78' }
end

Any help or guidance is much appreciated. Thank you!!

dupa
  • 13
  • 5
  • Actually what I think Im looking for is to create some ruby code that I can use in conjunction with inspec tests since the inspec will be a ruby file. – dupa Dec 17 '21 at 16:51
  • Since you want to mix and match contents of a file with the DNS configuration, having a shell script do all the checks and returning appropriate `stdout`/`stderr` is a good option. – seshadri_c Dec 20 '21 at 07:15

0 Answers0