Closed reidjc closed 6 years ago
I don't think this possible due to the fact that the network_interface
resource tests values that have a direct mapping to a specific machine.
e.g.
describe azure_network_interface('myNic') do
it {should have_ip_configuration('name' => 'myIpCfg', 'subnet' => 'mySubnet', 'private_ip_address_allocation' => 'static', 'private_ip_address' => '1.2.3.4'}
end
With the above how would you test against a private ip on the second instance count without targeting ('myNIC-2') directly?
After further discussion this should be supported.
The following tests now support matching on <resource-name>-x
for the azure_network_interface resource
describe azure_network_interface('myNic') do
its('security_group') {should be 'mySG'}
its('internal_dns_name_label') {should be 'myVM.internal'}
its('enable_ip_forwarding') {should be false}
its('dns_servers') {should be ['8.8.8.8']}
it {should have_tag('foo' => 'bar')}
end
For testing unique attributes on individual resources we can deploy a Ruby loop within the policy document.
(1..2).each do |i|
describe azure_network_interface("myNic-#{i}") do
it {should exist}
it {should have_ip_configuration('name' => 'myIpCfg', 'subnet' => 'mySubnet', 'private_ip_address_allocation' => 'static', 'private_ip_address' => "1.2.3.#{i}", 'load_balancer_backend_address_pools' => ['myPool'])}
end
end
Policy only takes an exact match: e.g.
web
does not work, butweb-1
does.