【发布时间】:2018-10-12 18:30:44
【问题描述】:
我对 ansible 在以下情况下寻求帮助有点陌生。我要做的是遍历数组'access_key_ids'并运行regex_search 过滤器。对于 regex_search 过滤器参数是 'item',它是来自 with_items 的变量。它不以这种方式工作,下面是我正在尝试的。
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
它将 event_response_access_key_ids 设为空。但是当我硬编码一个值而不是“项目”时,它可以工作
谢谢。
【问题讨论】:
标签: ansible yaml jinja2 ansible-2.x