Skip to content

Instantly share code, notes, and snippets.

@nmartins0611
Created August 22, 2023 09:23
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Regex Filter playbook to process patterns for hostnames
##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