I have a number of user public keys, obtained via rest call made with the URI module, and I want to pull out the uid contained within that key. Here is the relevant line of my role
- name: find users UID within key
debug:
msg: uid is "{{ item.content | regex_search( 'unixid=(\d+)', '\\1') }}"
this fails with the error:
'NoneType' object has no attribute 'group'
If I use -vvv on ansible I find that it's failing on this line
file "/usr/lib/python3.6/site-package/ansible/plugins/filter/core.py", line 156, in regex_search
match = int(re.match(r'\\(\d+)', arg).group(1))
By comparison if I do the same regex without the group search the command works fine, other then returning more then the id I want.
I was able to get the desired functionality by chaining two regex_search commands together, but it's ugly. I'd rather know why groups aren't working for regex_search.