mirror of
https://github.com/inspec/inspec
synced 2024-11-10 15:14:23 +00:00
Remove ruby headers from azure docs.
Signed-off-by: Jared Quick <jquick@chef.io>
This commit is contained in:
parent
7dc9ab8445
commit
3623454153
4 changed files with 21 additions and 136 deletions
|
@ -8,11 +8,9 @@ Use the `azure_generic_resource` InSpec audit resource to test any valid Azure R
|
|||
|
||||
## Syntax
|
||||
|
||||
```ruby
|
||||
describe azure_generic_resource(group_name: 'MyResourceGroup', name: 'MyResource') do
|
||||
its('property') { should eq 'value' }
|
||||
end
|
||||
```
|
||||
|
||||
where
|
||||
|
||||
|
@ -23,8 +21,6 @@ where
|
|||
|
||||
The options that can be passed to the resource are as follows.
|
||||
|
||||
The options that can be passed to the resource are as follows.
|
||||
|
||||
* `group_name`, the Azure resource group to be tested. Example: 'MyResourceGroup' (required)
|
||||
* `name`, the name of the Azure resource to test. Example: 'MyVM'
|
||||
* `type`, the Azure resource type. Example: 'Microsoft.Compute/virtualMachines'
|
||||
|
@ -47,12 +43,9 @@ There are _normally_ three standard tests that can be performed on a resource.
|
|||
|
||||
## Example
|
||||
|
||||
```ruby
|
||||
describe azure_generic_resource(group_name: 'Inspec-Azure', name: 'Linux-Internal-VM') do
|
||||
its('location') { should eq 'westeurope' }
|
||||
end
|
||||
```
|
||||
```
|
||||
|
||||
## Properties
|
||||
|
||||
|
@ -78,4 +71,4 @@ Please see the integration tests for in depth examples of how this resource can
|
|||
## Matchers
|
||||
|
||||
For a full list of available matchers please visit our [matchers page](https://www.inspec.io/docs/reference/matchers/).
|
||||
|
||||
|
||||
|
|
|
@ -10,16 +10,13 @@ Use the `azure_resource_group_resource_counts` InSpec audit resource to check th
|
|||
|
||||
The name of the resource group is specified as a parameter on the resource:
|
||||
|
||||
```ruby
|
||||
describe azure_resource_group(name: 'MyResourceGroup') do
|
||||
its('property') { should eq 'value' }
|
||||
its('property') { should eq 'value' }
|
||||
end
|
||||
```
|
||||
|
||||
where
|
||||
|
||||
* Resource Parameters
|
||||
* `MyResourceGroup` is the name of the resource group being interrogated
|
||||
* `MyResourceGroup` is the name of the resource group being interrogated
|
||||
* `property` is one a resource property
|
||||
* `value` is the expected output from the matcher
|
||||
|
||||
|
@ -35,14 +32,12 @@ Please refer the integration tests for more in depth examples:
|
|||
|
||||
### Test Resource Group has the correct number of resources
|
||||
|
||||
```ruby
|
||||
describe azure_resource_group_resource_counts(name: 'Inspec-Azure') do
|
||||
its('total') { should eq 7}
|
||||
```
|
||||
end
|
||||
|
||||
### Ensure that the Resource Group contains the correct resources
|
||||
|
||||
```ruby
|
||||
describe azure_resource_group_resource_counts(name: 'Inspec-Azure') do
|
||||
its('total') { should eq 7 }
|
||||
its('vm_count') { should eq 2 }
|
||||
|
@ -51,7 +46,6 @@ Please refer the integration tests for more in depth examples:
|
|||
its('sa_count') { should eq 1 }
|
||||
its('vnet_count') { should eq 1 }
|
||||
end
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
|
@ -82,13 +76,11 @@ When the options have been set as well as the environment variables, the environ
|
|||
|
||||
### Parameter Example
|
||||
|
||||
```ruby
|
||||
describe azure_resource_group_resource_counts(name: 'ChefAutomate') do
|
||||
its('total') { should eq 7}
|
||||
its('nic_count') { should eq 1 }
|
||||
its('vm_count') { should eq 1 }
|
||||
its('total') { should eq 7}
|
||||
its('nic_count') { should eq 1 }
|
||||
its('vm_count') { should eq 1 }
|
||||
end
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
|
@ -106,17 +98,13 @@ This InSpec audit resource has the following properties:
|
|||
|
||||
Returns the name of the resource group.
|
||||
|
||||
```ruby
|
||||
its(name) { should cmp 'nugget' }
|
||||
```
|
||||
|
||||
### location
|
||||
|
||||
Returns where in Azure the resource group is located.
|
||||
|
||||
```ruby
|
||||
its(location) { should cmp 'us-west' }
|
||||
```
|
||||
|
||||
### id
|
||||
|
||||
|
@ -124,17 +112,13 @@ Returns the full qualified ID of the resource group.
|
|||
|
||||
This is in the format `/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/<RESOURCE_GROUP_NAME>`.
|
||||
|
||||
```ruby
|
||||
its(id) { should cmp 'FQDN' }
|
||||
```
|
||||
|
||||
### provisioning_state
|
||||
|
||||
The provisioning state of the resource group.
|
||||
|
||||
```ruby
|
||||
its(provisioning_state) { should cmp '????' }
|
||||
```
|
||||
|
||||
### subscription_id
|
||||
|
||||
|
@ -142,57 +126,43 @@ Returns the subscription ID which contains the resource group.
|
|||
|
||||
This is derived from the `id`.
|
||||
|
||||
```ruby
|
||||
its(subscription_id) { should cmp '????' }
|
||||
```
|
||||
|
||||
### total
|
||||
|
||||
The total number of resources in the resource group
|
||||
|
||||
```ruby
|
||||
its(total) { should eq 5 }
|
||||
```
|
||||
|
||||
### nic_count
|
||||
|
||||
The number of network interface cards in the resource group
|
||||
|
||||
```ruby
|
||||
its(nic_count) { should eq 2 }
|
||||
```
|
||||
|
||||
### vm_count
|
||||
|
||||
The number of virtual machines in the resource group
|
||||
|
||||
```ruby
|
||||
its(vm_count) { should eq 5 }
|
||||
```
|
||||
|
||||
### vnet_count
|
||||
|
||||
The number of virtual networks in the resource group
|
||||
|
||||
```ruby
|
||||
its(vnet_count) { should eq 5 }
|
||||
```
|
||||
|
||||
### sa_count
|
||||
|
||||
The number of storage accounts in the resource group
|
||||
|
||||
```ruby
|
||||
its(sa_count) { should eq 5 }
|
||||
```
|
||||
|
||||
### public_ip_count
|
||||
|
||||
The number of Public IP Addresses in the resource group
|
||||
|
||||
```ruby
|
||||
its(public_ip_count) { should eq 5 }
|
||||
```
|
||||
|
||||
### managed_disk_image_count
|
||||
|
||||
|
@ -200,9 +170,7 @@ The number of managed disk images that are in the resource group.
|
|||
|
||||
These are the items from which managed disks are created which are attached to machines. Generally the images are created from a base image or a custom image (e.g. Packer)
|
||||
|
||||
```ruby
|
||||
its(managed_disk_image_count) { should eq 5 }
|
||||
```
|
||||
|
||||
### managed_disk_count
|
||||
|
||||
|
@ -210,9 +178,7 @@ The number of managed disks in the resource group.
|
|||
|
||||
If a resource group contains one virtual machine with an OS disk and 2 data disks that are all Managed Disks, then the count would be 3.
|
||||
|
||||
```ruby
|
||||
its(managed_disk_count) { should eq 3 }
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
|
@ -259,10 +225,9 @@ Use this resource to test `Microsoft.Network/publicIPAddresses`
|
|||
|
||||
With these methods the following tests are possible
|
||||
|
||||
```ruby
|
||||
it { should have_nics }
|
||||
it { should_not have_extensions }
|
||||
```
|
||||
|
||||
## Tags
|
||||
|
||||
It is possible to test the tags that have been assigned to the resource. There are a number of properties that can be called to check that it has tags, that it has the correct number and that the correct ones are assigned.
|
||||
|
@ -271,25 +236,19 @@ It is possible to test the tags that have been assigned to the resource. There a
|
|||
|
||||
This is a simple test to see if the machine has tags assigned to it or not.
|
||||
|
||||
```ruby
|
||||
it { should have_tags }
|
||||
```
|
||||
|
||||
### tag\_count
|
||||
|
||||
Returns the number of tags that are assigned to the resource
|
||||
|
||||
```ruby
|
||||
its ('tag_count') { should eq 2 }
|
||||
```
|
||||
|
||||
### tags
|
||||
|
||||
It is possible to check if a specific tag has been set on the resource.
|
||||
|
||||
```ruby
|
||||
its('tags') { should include 'Owner' }
|
||||
```
|
||||
|
||||
### xxx\_tag
|
||||
|
||||
|
@ -303,9 +262,7 @@ For example, if the following tag is set on a resource:
|
|||
|
||||
Then a property is available called `Owner_tag`.
|
||||
|
||||
```ruby
|
||||
its('Owner_tag') { should cmp 'Russell Seymour' }
|
||||
```
|
||||
|
||||
Note: The tag name is case sensitive which makes the test case sensitive. E.g. `owner_tag` does not equal `Owner_tag`.
|
||||
|
||||
|
@ -319,14 +276,12 @@ Please refer the integration tests for more in depth examples:
|
|||
|
||||
### Test Resource Group has the correct number of resources
|
||||
|
||||
```ruby
|
||||
describe azure_resource_group_resource_counts(name: 'Inspec-Azure') do
|
||||
its('total') { should eq 7}
|
||||
```
|
||||
end
|
||||
|
||||
### Ensure that the Resource Group contains the correct resources
|
||||
|
||||
```ruby
|
||||
describe azure_resource_group_resource_counts(name: 'Inspec-Azure') do
|
||||
its('total') { should eq 7 }
|
||||
its('vm_count') { should eq 2 }
|
||||
|
@ -335,8 +290,7 @@ Please refer the integration tests for more in depth examples:
|
|||
its('sa_count') { should eq 1 }
|
||||
its('vnet_count') { should eq 1 }
|
||||
end
|
||||
```
|
||||
|
||||
## References
|
||||
|
||||
- [Azure Ruby SDK - Resources](https://github.com/Azure/azure-sdk-for-ruby/tree/master/management/azure_mgmt_resources)
|
||||
- [Azure Ruby SDK - Resources](https://github.com/Azure/azure-sdk-for-ruby/tree/master/management/azure_mgmt_resources)
|
||||
|
|
|
@ -10,17 +10,14 @@ Use the `azure_virtual_machine` InSpec audit resource to ensure that a Virtual M
|
|||
|
||||
The name of the machine and the resourece group are required as properties to the resource.
|
||||
|
||||
```ruby
|
||||
describe azure_virtual_machine(group_name: 'MyResourceGroup', name: 'MyVM') do
|
||||
its('property') { should eq 'value' }
|
||||
end
|
||||
```
|
||||
|
||||
where
|
||||
|
||||
* Resource Parameters
|
||||
* `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 resource group that the machine is in.
|
||||
* `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 resource group that the machine is in.
|
||||
* `property` is one of
|
||||
* `value` is the expected output from the matcher
|
||||
|
||||
|
@ -42,12 +39,10 @@ When the options have been set as well as the environment variables, the environ
|
|||
|
||||
For example:
|
||||
|
||||
```ruby
|
||||
describe azure_virtual_machine(group_name: 'Inspec-Azure', name: 'Linux-Internal-VM') do
|
||||
its('os_type') { should eq 'Linux' }
|
||||
it { should have_boot_diagnostics }
|
||||
end
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
|
@ -62,21 +57,17 @@ Please refer the integration tests for more in depth examples:
|
|||
|
||||
### Test that the machine was built from a Windows image
|
||||
|
||||
```ruby
|
||||
describe azure_virtual_machine(name: 'Windows-Internal-VM', group_name: 'Inspec-Azure') do
|
||||
its('publisher') { should eq 'MicrosoftWindowsServer' }
|
||||
its('offer') { should eq 'WindowsServer' }
|
||||
its('sku') { should eq '2012-R2-Datacenter' }
|
||||
end
|
||||
```
|
||||
|
||||
### Ensure the machine is in the correct location
|
||||
|
||||
```ruby
|
||||
describe azure_virtual_machine(name: 'Linux-Internal-VM', resource_group: 'Inspec-Azure') do
|
||||
its('location') { should eq 'westeurope' }
|
||||
end
|
||||
```
|
||||
<br>
|
||||
|
||||
## Properties
|
||||
|
@ -97,9 +88,7 @@ THe Azure Resource type. For a virtual machine this will always return `Microsof
|
|||
|
||||
Where the machine is located
|
||||
|
||||
```ruby
|
||||
its('location') { should eq 'westeurope' }
|
||||
```
|
||||
its('location') { should eq 'westeurope' }
|
||||
|
||||
### name
|
||||
|
||||
|
@ -137,9 +126,7 @@ Determine if the operating system disk is a Managed Disks or not.
|
|||
|
||||
This test can be used in the following way:
|
||||
|
||||
```ruby
|
||||
it { should have_managed_osdisk }
|
||||
```
|
||||
it { should have_managed_osdisk }
|
||||
|
||||
### caching
|
||||
|
||||
|
@ -157,9 +144,7 @@ Returns the size of the operating system disk.
|
|||
|
||||
Denotes if the machine has data disks attached to it or not.
|
||||
|
||||
```ruby
|
||||
it { should have_data_disks }
|
||||
```
|
||||
it { should have_data_disks }
|
||||
|
||||
### data\_disk\_count
|
||||
|
||||
|
@ -173,9 +158,7 @@ This provides the storage account type for a machine that is using managed disks
|
|||
|
||||
The size of the machine in Azure
|
||||
|
||||
```ruby
|
||||
its('vm_size') { should eq 'Standard_DS2_v2' }
|
||||
```
|
||||
its('vm_size') { should eq 'Standard_DS2_v2' }
|
||||
|
||||
### computer\_name
|
||||
|
||||
|
@ -193,9 +176,7 @@ Returns a boolean to state if the machine has NICs connected or not.
|
|||
|
||||
This has can be used in the following way:
|
||||
|
||||
```ruby
|
||||
it { should have_nics }
|
||||
```
|
||||
|
||||
### nic\_count
|
||||
|
||||
|
@ -205,9 +186,7 @@ The number of network interface cards that have been attached to the machine
|
|||
|
||||
This returns an array of the NIC ids that are connected to the machine. This means that it possible to check that the machine has the correct NIC(s) attached and thus on the correct subnet.
|
||||
|
||||
```ruby
|
||||
its('connected_nics') { should include /Inspec-NIC-1/ }
|
||||
```
|
||||
|
||||
Note the use of the regular expression here. This is because the NIC id is a long string that contains the subscription id, resource group, machine id as well as other things. By using the regular expression the NIC can be checked withouth breaking this string up. It also means that other tests can be performed.
|
||||
|
||||
|
@ -217,17 +196,13 @@ An example of the id string is `/subscriptions/1e0b427a-d58b-494e-ae4f-ee558463e
|
|||
|
||||
Returns a boolean to denote if the machine is accessible using a password.
|
||||
|
||||
```ruby
|
||||
it { should have_password_authentication }
|
||||
```
|
||||
it { should have_password_authentication }
|
||||
|
||||
### password\_authentication?
|
||||
|
||||
Boolean to state of password authentication is enabled or not for the admin user.
|
||||
|
||||
```ruby
|
||||
its('password_authentication?') { should be false }
|
||||
```
|
||||
|
||||
This only applies to Linux machines and will always return `true` on Windows.
|
||||
|
||||
|
@ -235,25 +210,19 @@ This only applies to Linux machines and will always return `true` on Windows.
|
|||
|
||||
Returns a boolean stating if the machine has custom data assigned to it.
|
||||
|
||||
```ruby
|
||||
it { should have_custom_data }
|
||||
```
|
||||
|
||||
### custom\_data?
|
||||
|
||||
Boolean to state if the machine has custom data or not
|
||||
|
||||
```ruby
|
||||
its('custom_data') { should be true }
|
||||
```
|
||||
|
||||
### have\_ssh\_keys
|
||||
|
||||
Boolean to state if the machine has SSH keys assigned to it
|
||||
|
||||
```ruby
|
||||
it { should have_ssh_keys }
|
||||
```
|
||||
|
||||
For a Windows machine this will always be false.
|
||||
|
||||
|
@ -261,9 +230,7 @@ For a Windows machine this will always be false.
|
|||
|
||||
Boolean to state of the machine is accessible using SSH keys
|
||||
|
||||
```ruby
|
||||
its('ssh_keys?') { should be true }
|
||||
```
|
||||
|
||||
### ssh\_key\_count
|
||||
|
||||
|
@ -277,25 +244,19 @@ Returns an array of the keys that are assigned to the machine. This is check if
|
|||
|
||||
Most SSH public keys have a signature at the end of them that can be tested. For example:
|
||||
|
||||
```ruby
|
||||
its('ssh_keys') { should include /azure@inspec.local/ }
|
||||
```
|
||||
|
||||
### boot\_diagnostics?
|
||||
|
||||
Boolean test to see if boot diagnostics have been enabled on the machine
|
||||
|
||||
```ruby
|
||||
it { should have_boot_diagnostics }
|
||||
```
|
||||
|
||||
### boot\_diagnostics\_storage\_uri
|
||||
|
||||
If boot diagnostics are enabled for the machine they will be saved in a storage account. This method returns the URI for the storage account.
|
||||
|
||||
```ruby
|
||||
its('boot_diagnostics_storage_uri') { should match 'ghjgjhgjg' }
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
|
@ -316,25 +277,19 @@ It is possible to test the tags that have been assigned to the resource. There a
|
|||
|
||||
This is a simple test to see if the machine has tags assigned to it or not.
|
||||
|
||||
```ruby
|
||||
it { should have_tags }
|
||||
```
|
||||
|
||||
### tag\_count
|
||||
|
||||
Returns the number of tags that are assigned to the resource
|
||||
|
||||
```ruby
|
||||
its ('tag_count') { should eq 2 }
|
||||
```
|
||||
|
||||
### tags
|
||||
|
||||
It is possible to check if a specific tag has been set on the resource.
|
||||
|
||||
```ruby
|
||||
its('tags') { should include 'Owner' }
|
||||
```
|
||||
|
||||
### xxx\_tag
|
||||
|
||||
|
@ -348,9 +303,7 @@ For example, if the following tag is set on a resource:
|
|||
|
||||
Then a test is available called `Owner_tag`.
|
||||
|
||||
```ruby
|
||||
its('Owner_tag') { should cmp 'Russell Seymour' }
|
||||
```
|
||||
|
||||
Note: The tag name is case sensitive which makes the test case sensitive. E.g. `owner_tag` does not equal `Owner_tag`.
|
||||
|
||||
|
|
|
@ -14,17 +14,14 @@ Use this resource to ensure that a specific data disk attached to a machine has
|
|||
|
||||
The name of the resource group and machine are required to use this resource.
|
||||
|
||||
```ruby
|
||||
describe azure_virtual_machine_data_disk(group_name: 'MyResourceGroup', name: 'MyVM') do
|
||||
its('property') { should eq 'value' }
|
||||
end
|
||||
```
|
||||
|
||||
where
|
||||
where
|
||||
|
||||
* Resource Parameters
|
||||
* `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.
|
||||
* `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.
|
||||
* `property` is a resource property
|
||||
* `value` is the expected output fdrom the matcher
|
||||
|
||||
|
@ -46,12 +43,10 @@ When the options have been set as well as the environment variables, the environ
|
|||
|
||||
For example:
|
||||
|
||||
```ruby
|
||||
describe azure_virtual_machine_data_disk(group_name: 'Inspec-Azure', name: 'Linux-Internal-VM') do
|
||||
its('count') { should cmp > 0 }
|
||||
it { should have_data_disks }
|
||||
end
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
|
@ -66,11 +61,9 @@ Please refer to the following integration tests for more in depth examples:
|
|||
|
||||
### Check that the first data disk is of the correct size
|
||||
|
||||
```ruby
|
||||
describe azure_virtual_machine_data_disk(group_name: 'Inspec-Azure', name: 'Linux-Internal-VM').where(number: 1) do
|
||||
its('size') { should cmp >= 15 }
|
||||
end
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
|
@ -87,34 +80,26 @@ Please refer to the following integration tests for more in depth examples:
|
|||
|
||||
Returns the number of data disks attached to the machine
|
||||
|
||||
```ruby
|
||||
its('count') { should eq 1 }
|
||||
```
|
||||
|
||||
### have\_data\_disks
|
||||
|
||||
Returns a boolean denoting if any data disks are attached to the machine
|
||||
|
||||
```ruby
|
||||
it { should have_data_disks }
|
||||
```
|
||||
|
||||
### have\_managed\_disks
|
||||
|
||||
Returns a boolean stating if the machine has Managed Disks for data disks.
|
||||
|
||||
```ruby
|
||||
it { should have_managed_disks }
|
||||
```
|
||||
|
||||
**The next set of attributes require the `where` operation to be used on the describe.**
|
||||
|
||||
The following code shows an example of how to use the where clause.
|
||||
|
||||
```ruby
|
||||
describe azure_virtual_machine_data_disk(group_name: 'Inspec-Azure', name: 'Windows-Internal-VM').where(number: 1)
|
||||
end
|
||||
```
|
||||
|
||||
### disk
|
||||
|
||||
|
@ -194,4 +179,4 @@ Use the `eq` matcher to test the equality of two values: `its('Port') { should e
|
|||
|
||||
Using `its('Port') { should eq 22 }` will fail because `22` is not a string value! Use the `cmp` matcher for less restrictive value comparisons.
|
||||
|
||||
**The following properties are ones that are applied to the virtual machine itself and not specfic disks**
|
||||
**The following properties are ones that are applied to the virtual machine itself and not specfic disks**
|
||||
|
|
Loading…
Reference in a new issue