FreeKB - Ansible split (cut a string into pieces)
www.freekb.net/Article?id=249718.06.2021 · Let's say you are using the vars plugin to create a variable, like this.. vars: foo: "Hello World" Or the set_fact module, like this. - set_fact: foo: "Hello World" The debug module can be used to print the variable. Notice the double curley braces {{ ... }}. Jinja2 uses double curley braces for variables. - name: output the content of the 'foo' variable debug: var: foo
FreeKB - Ansible split (cut a string into pieces)
www.freekb.net › ArticleJun 18, 2021 · Here is how you would use split with register output. - name: split at a single whitespace, print field 1 debug: msg: "{{ out.stdout.split(' ')[0] }}" The set_fact module can be used to create a variable that contains the split value. - set_fact: value: "{{ out.stdout.split(' ')[0] }}"