Sunday, March 25, 2018

Ansible: ERROR: tag(s) not found in playbook:

I was getting this error when I was running an ansible playbook from my java application. And surprisingly when I copy the exact same command on the command line then it ran just fine.  Every time I am getting an error as shown below:
ERROR: tag(s) not found in playbook:  foobar.  possible values: foobar
I spent many hours but could not understand why it is failing to run from java app but runs fine from command line. Then I started playing with the command in java and placed the "-t foobar" at different places, such as after the "ansible-playbook" command or at the end of the statement, or along with an extra variable. Every time it failed with same error.
Then I noticed that there are two spaces before the "foobar" in the error.  And that was like the eureka moment for me. I changed the java code to use "-tfoobar" (without space between "-t" and tagname). That's it, it worked.
It seems the library I was using (commons-exec from apache) passes the arguments in such a way that ansible does not like space after "-t" option. But space works just fine when running the command via command line.

No comments:

Post a Comment