Created
March 21, 2018 17:45
-
-
Save deekayen/3698782d26be4260abe464bfdd8aef9c to your computer and use it in GitHub Desktop.
Ansible variable substring from regex_replace
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
--- | |
# RUN: ansible-playbook -i localhost, substr.yml | |
- hosts: localhost | |
vars: | |
stuff: deekayen@WINDOMAIN.COM | |
ansible_user: deekayen | |
tasks: | |
- name: "Crop stuff var into substr var." | |
set_fact: | |
substr: "{{ stuff | regex_replace('^(.*?)@WINDOMAIN.COM$', '\\1') }}" | |
- name: "Return deekayen." | |
debug: | |
var: substr |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment