Red Hat Ansible
I’ve come across this
Ansible error recently. It made no sense because I had a fully populated hosts file with multiple hosts and groups.
Specifically, I was running an existing playbook and limiting its execution to just srv1:
Ansible kept giving me these errors, which seemed like an issue with (new) server
srv1 I was trying to configure:
I eventually tried the same command without
limit option, and got the same error, but this time for the
Ansible server group
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
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.
Hope this helps, have fun!