extending conditional task execution

Before I just code something up and submit it I wanted to float this one by the list to see if anyone had a different idea or opposed it entirely.

I hit a situation today where I needed to conditional run a task based on a pattern as opposed to an absolute value.

Ansible supports conditionals but it uses a simple eval statement so I can't (to my knowledge) import re and then do a match. That's understandable and probably a good idea. That still doesn't help me with my problem though.

I'm thinking a specialized task conditional, like only_if_match, would be best where its value would be used to perform a re.search() and return a boolean result. I don't like the idea of adding another key, but determining if a string is something to eval or a regex to compile and match would be worse IMO.

Thoughts?

<tim/>

I'm thinking a specialized task conditional, like only_if_match, would be best where its value would be used to perform a re.search() and return a boolean result. I don't like the idea of adding another key, but determining if a string is something to eval or a regex to compile and match would be worse IMO.

I am against adding new syntax here.

It seems easiest if runner/__init__.py just imports "re" such that this will work for you.

Then you should be able to do all the string methods that take regexes just fine.

--Michael

OK. That works for me.

I was thinking about avoiding an unnecessary import (re is almost definitely being loaded elsewhere tho) and the ability to compile & cache a pattern. Nice to have but not necessary.

<tim/>