Questions tagged [inspec]

Questions related to the InSpec testing framework by Chef.

InSpec is an -based audit testing framework. Based on the specification described in its , the state of a system (mostly a server or container) can be verified, very similar to .

Links:

119 questions
8
votes
2 answers

How to limit InSpec test to a specific OS Version

We have a cookbook that is used on centos 6 and 7 machines. On 7 it installs the latest version of node, on 6 it installs a specific version of node. Also on 6 it installs certain other packages that we don't install on 7. I am trying to figure…
Kenneth Baltrinic
  • 2,941
  • 2
  • 28
  • 45
6
votes
2 answers

How do I access Chef data_bags in InSpec

I am writing InSpec tests for some new Chef recipes I am working on. I would like to utilise the data_bags used by the cookbooks to iterate through the data bag items. I can't figure out how to access them in my InSpec tests! The recipes are using…
5
votes
1 answer

Can I query jmx port using curl to check that jmx is working fine?

Is it possible to query some/any data from the jmx port using curl? I am writing an inspec(chef) test to check that jmx is working fine. # curl https://localhost:9114 curl: (35) Encountered end of file # curl -s -w "%{http_code}\n"…
user674669
  • 10,681
  • 15
  • 72
  • 105
5
votes
2 answers

Inspec test multiple entities

I am writing inspec tests for my chef recipes where there are 5 files which needs to tested for their mode. All of them should have the same mode 0755. describe file('/dev') do its('mode') { should cmp '00755' } end This is the sytax I am using.…
codec
  • 7,978
  • 26
  • 71
  • 127
4
votes
1 answer

Possible to use Chef variables within Inspec?

I'm learning to write integration tests for my Chef cookbooks. Is it possible to reference variables from the attributes folder within my test? Here's my test to make sure httpd and php are installed properly. However, I have additional packages I…
sdot257
  • 10,046
  • 26
  • 88
  • 122
4
votes
2 answers

Check content of file with InSpec if it exists

I'm writing a Chef InSpec test in ruby to check the contents of the files for 'umask 077'. The issue is that for a few of the files in my array that I'm checking for do not exist. I'm trying to exclude nil files and re-push them, but it seems to…
Blooze
  • 1,987
  • 4
  • 16
  • 19
2
votes
1 answer

chef inspec validation of the nested json file

I am using chef inspec to validate in the below json file whether annotation is equal to Test. "imdata": [ { "aaaPwdStrengthProfile": { "attributes": { "annotation": "Test", } } …
2
votes
2 answers

inspec run a single control as sudo

I am using inspec to verify some AMIs that I am building, and in the main I want the controls in the profile to run as a normal user so I can test as a standard user would see things. However there area couple of controls that I want to run as root…
apr_1985
  • 1,764
  • 2
  • 14
  • 27
2
votes
2 answers

InSpec: "Cannot load since it is not listed as a dependency" when dependency is defined

In InSpec 1.9.0 I defined the following profile with dependency, including all controls from the dependent profile. However, when executing I get the error indicating the profile "is not listed as dependency" What am I missing? inspec.yml: name:…
techraf
  • 64,883
  • 27
  • 193
  • 198
2
votes
1 answer

inspect ssh connection is not working but ssh connection is allow

I am trying to run all my inspec test before to deploy the chef recipe. I want to know what is the initial state of my instances. I tested the ssh connection with: ssh -i $HOME/key.pem centos@server_ip_address and the connection is allow, but when…
Robert
  • 10,403
  • 14
  • 67
  • 117
2
votes
2 answers

Execute a command before or after an InSpec test

I wonder if anyone has or can create a sample code which demonstrates how to execute a shell script after (or before) InSpec test. The primary idea is to use RSpec after block to clean up resources allocated during the test run.
roman
  • 892
  • 9
  • 26
2
votes
2 answers

Nested resources in Chef InSpec

Is it possible to use one resource inside other resource in Chef InSpec? Example: describe command('su srijava') do describe file ('/app/java/latest') do it{ should exist } end end It throws an error…
saurg
  • 327
  • 1
  • 3
  • 17
1
vote
1 answer

How to write a Chef Inspec test for the Chef Infra 'sudo' resource?

Versions Chef Workstation version: 22.7.1006 Chef InSpec version: 4.56.20 Chef CLI version: 5.6.1 Chef Habitat version: 1.6.420 Test Kitchen version: 3.3.1 Cookstyle version: 7.32.1 Chef Infra Client version: 17.10.0 I'm using Kitchen to provision…
Craftonix - AA
  • 410
  • 5
  • 13
1
vote
0 answers

Chef Inspec - How to Read Custom Properties in Files

I'm currently using Chef Inspec and want to read the content within some of my SH files. How can I get ChefInspec to read some of the properties contained within them: Ex: ex_sh_file = location/ex_file.sh' describe bash(ex_sh_file) do it { should…
Dodkm
  • 11
  • 2
1
vote
1 answer

inspec-aws errors on running an exec

Any idea what im doing wrong i have chefworkstation installed: $ chef -v Chef Workstation version: 21.4.365 Chef Infra Client version: 16.12.3 Chef InSpec version: 4.29.3 Chef CLI version: 4.0.0 Chef Habitat version: 1.6.288 Test Kitchen version:…
Staggerlee011
  • 847
  • 2
  • 13
  • 23
1
2 3 4 5 6 7 8