Ansible and --limit option

[WARNING]: Could not match supplied host pattern, ignoring: VM2

This means ‘VM2’ host is not present in your inventory.ies. In your functioning example, you go for an IP address, which in turn would be in your inventory.ies.

Inventories are not like /etc/hosts file, and there is no DNS resolution in play at this point; hosts you’re passing to --limit should match an host present in your inventories.

Just run ansible -i <yourInventoryFilesPaths> --list-hosts all and pick one of those, or alias them.

Hope this makes sense. If not, please tell and I’ll try to be more specific.

3 Likes