Created
March 21, 2018 17:45
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