Created
August 22, 2023 09:23
-
-
Save nmartins0611/6554b586bdbd780ff7dd9002ebf215f9 to your computer and use it in GitHub Desktop.
Regex Filter playbook to process patterns for hostnames
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##example | |
--- | |
- name: Regex Processing for hostnames | |
hosts: localhost | |
connection: local | |
gather_facts: false | |
vars: | |
eda_input: "{{ ansible_eda.event.payload.text }}" # access event payload | |
regex_pattern: '\b(\w+\.mydomain\.com)\b' # can supply via vars.yml | |
tasks: | |
- name: Extract switch name from text | |
set_fact: | |
cacheable: yes | |
switch_devices: "{{ eda_input | regex_findall(regex_pattern) }}" | |
regex_proc: done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment