inspec/docs/resources/azure_virtual_machine_datadisks.md
Russell Seymour ef323e3b31 Updated resource to follow RSpec convention
Closes #31

Signed-off-by: Russell Seymour <russell.seymour@turtlesystems.co.uk>
2017-03-02 14:08:33 +00:00

2.1 KiB

title
About the azure_virtual_machine_datadisks Resource

azure_virtual_machine_datadisks

Use this resource to check that the correct number of data disks have been applied to the machine and that they are of the correct size.

References

Syntax

The name of the resource group and machine are required to use this resource.

describe azure_virtual_machine(name: 'MyVM', resource_group: 'MyResourceGroup') do
  its('matcher') { should eq 'value' }
end

where

  • MyVm is the name of the virtual machine as seen in Azure. (It is not the hostname of the machine)
  • MyResourceGroup is the name of the resouce group that the machine is in.
  • matcher is one of
    • count the number of data disks attached to the machine
    • has_data_disks? boolean test denoting if data disks are attached
    • entries used with the where filter to check the size of a disk
  • value is the expected output fdrom the matcher

## Matchers

This InSpec audit resource has the following matchers:

eq

Use the eq matcher to test the equality of two values: its('Port') { should eq '22' }.

Using its('Port') { should eq 22 } will fail because 22 is not a string value! Use the cmp matcher for less restrictive value comparisons.

count

Returns the number of data disks attached to the machine

its('count') { should eq 1 }

has_data_disks?

Returns a boolean denoting if any data disks are attached to the machine

it { should have_data_disks }

entries

The entries filter can be used to check the attributes of indivdual data disks:

its('entries') { should_not be_empty }

This matcher is best used in conjunction with filters. For example the following tests that the first data disk has a capacity greater than 10gb.

describe azure_virtual_machine_datadisks(name: 'MyVM', resource_group: 'MyResourceGroup').where { disk.zero? and size > 10 } do
  its('entries') { should_not be_empty }
end

Examples

None