Tool/ansible
ansible에서 문자열 split 방법
귀염둥이채원
2019. 3. 18. 15:10
ansible에서는 split()을 사용하여 문자열을 분할이 가능하다.
split()은 jinja2 필터가 아니고, python 함수입니다.
# example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | - hosts: all vars: test: "This single line should be split based on white space" tasks: - debug: msg: "{{ test.split() }}" output ------ ok: [localhost] => { "msg": [ "This", "single", "line", "should", "be", "split", "based", "on", "white", "space" ] } | cs |
# jinja2 filter
http://jinja.pocoo.org/docs/2.10/templates/#filters
# ansible filter
https://docs.ansible.com/ansible/latest/user_guide/playbooks_filters.html#playbooks-filters
# 참고 사이트
http://www.mydailytutorials.com/how-to-split-strings-and-join-them-in-a%E2%80%8Bnsibl%E2%80%8Be/