volanja/ansible_spec

Do not fail on no hosts matched

philbert opened this issue · 0 comments

The failure condition for ansible_spec when no hosts are matched in the inventory is a problem for my use case.

I am using an ec2 dynamic inventory for a complex system that has 9 different ansible groups with matching playbooks.

In a development environment it is common to create only the servers which are necessary for testing, leaving some of groups without any hosts. This is especially the case if we are trying to test our ansible playbooks with serverspec.

For this reason I changed
fail "no hosts matched"
to
puts "no hosts matched for #{var["hosts"]}"
which is a preferable output, allowing us to proceed with testing.