Ansible kept giving me these errors, which seemed like an issue with (new) server srv1 I was trying to configure:
Could not match supplied host pattern, ignoring: srv1
I eventually tried the same command without limit option, and got the same error, but this time for the Ansible server group [online].
Turns out, I didn’t initialise my Ansible environment correctly: ansible.cfg didn’t specify hosts file location, because of this the hostname was expected in its default location instead of my ansible homedir.
The fix for this was to implicitly define Ansible hosts location in ansible.cfg file, under the [defaults] section:
inventory=/Users/greys/proj/ansible/hosts
This fixed the issue and taught me a lesson: “could not match supplied host pattern” isn’t about pattern at all, it’s most likely about you not pointing Ansible to the correct hosts file that defines your groups and servers.
I'm a principal consultant with Tech Stack Solutions. I help with cloud architectrure, AWS deployments and automated management of Unix/Linux infrastructure. Get in touch!