Ansible regex filter along with_items

Hi,

I’m kinda new to ansible seeking helop with below scenario. what I’m trying to do is iterate over the array ‘access_key_ids’ and run regex_search filter. for the regex_search filter argument is ‘item’ which is the variable from with_items. It does not work this way below is what I’m trying.

name: Set Fatcs

block:

# extract access key ids from get event response

  • set_fact:

event_response_access_key_ids: “{{event_response_access_key_ids}} + [{{event_response.content | regex_search(item)}}]”

with_items: “{{access_key_ids}}”

# check if the response contains access key id for the license

  • set_fact:

scwx_output: “{{ (event_response_access_key_ids | length > 0 ) | ternary(event_response, ‘License Key does not match with available sensors’)}}”

when: event_response.json is undefined

It gives event_response_access_key_ids as empty. but when I hard code a value instead of ‘item’ it works

Thanks.