vigri
vigri

Reputation: 477

Include ip address of node in Chef InSpec test

I'm running InSpec tests through Test Kitchen

My InSpec test shall ensure, that the output of a curl command is "HelloWorld!"

The following code-block works as desired:

describe command("curl localhost}") do
    its('stdout') { should match /HelloWorld!/ }
end

Question

How can I include a nodes attribute (ip address) inside my curl test?

In .erb-templates I can use <%= node['ipaddress'] %>

The following approch isn't working

describe command("curl #{:ipaddress}") do
    its('stdout') { should match /HelloWorld!/ }
end

Upvotes: 0

Views: 569

Answers (1)

coderanger
coderanger

Reputation: 54267

This is not specifically supported. InSpec is totally separate from Chef and has no knowledge of Chef and Ohai stuff. You would probably want to make a little implementation yourself, but check the os helper in InSpec.

Upvotes: 1

Related Questions