Search code examples
ansibleansible-2.xansible-inventory

Do patterns not work with ansible-playbook and --limit?


I want to limit an ansible run to all webservers which are not in the windows group. I get this done when I create a new group:

[test]
webservers:!windows

and run it like this:

ansible-playbook -i inventories/staging/ site.yml --limit test

But when I try to avoid the group definition and put all into the limit statement it fails with !windows event not found

ansible-playbook -i inventories/staging/ site.yml --limit "webservers:!windows" 

Is this not supported or do I something wrong?


Solution

  • ! is a special character in bash to expand previous commands.

    You should use single quotes to avoid bash expansion: --limit 'webservers:!windows'