Search code examples
chef-infratest-kitcheninspec

InSpec should_be_listening Test Fails When Port is Open


Environment

chefdk 1.3.40

berks 5.6.4

kitchen 1.16.0

vagrant 1.9.3

After a 'kitchen login', we can see that port 80 has been opened

sudo iptables-save | grep 80
-A IN_public_allow -p tcp -m tcp --dport 80 -m conntrack --ctstate NEW -j ACCEPT

However, when running 'kitchen verify' the test fails:

PORT 80
[MAJR]  should be listening
expected 'Port 80.listening?' to return true, got false

Here is the Inspec test:

describe port(80) do
  it { should be_listening }
end

Solution

  • Based on the commands provided, there is no indication that any program is actually listening to port 80. The iptables-save output only shows a firewall rule that permits incoming connections.

    InSpec itself calls netstat -tulpen to gather information about listening sockets. You might want to use this to verify manually.