Extrapolate data from facts?

I would like to be able to test Macs for the major version of OS X, ie. Lion, Mountain Lion, Mavericks. I see a fact called “ansible_distribution_version” which is equal to the whole software rev, like “10.9.4” Can I have ansible perform some operation like cut or awk so I can wind up with “10.9” or “10.8”?

You may be interested in the regex replace filter, as shown in the docs here:

http://docs.ansible.com/playbooks_variables.html#id26

{{ 'foobar' | regex_replace('^f.*o(.*)$', '\1') }}