Skip to content

Instantly share code, notes, and snippets.

@halberom
Created October 31, 2017 11:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save halberom/f5d3551da0f61186b920f1bd38934662 to your computer and use it in GitHub Desktop.
Save halberom/f5d3551da0f61186b920f1bd38934662 to your computer and use it in GitHub Desktop.
ansible - example of splitting on \
PLAY [localhost] ***************************************************************************************************************************************************************************************************************************************************************
TASK [Split user name from account var] ****************************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
"msg": "I want just the username - someone"
}
PLAY RECAP *********************************************************************************************************************************************************************************************************************************************************************
localhost : ok=1 changed=0 unreachable=0 failed=0
---
- hosts: localhost
gather_facts: false
vars:
account: 'somedomain\\someone'
tasks:
- name: Split user name from account var
debug:
msg: I want just the username - {{ account.split('\\')[1] }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment