Skip to content

Instantly share code, notes, and snippets.

@tszpinda
Created October 7, 2016 14:01
Show Gist options
  • Save tszpinda/2144c18057cbd1671cdfca21c044bd6f to your computer and use it in GitHub Desktop.
Save tszpinda/2144c18057cbd1671cdfca21c044bd6f to your computer and use it in GitHub Desktop.
ansible local regex
---
- hosts: localhost
connection: local
gather_facts: False
tasks:
- set_fact:
ip: "192.172.32.30"
- set_fact:
x: "{{ip| regex_replace('^(\\d{1,3}\\.\\d{1,3}).*', '\\1') }}"
- debug: var=x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment