
Quiero generar texto con tabulación como separador usando ansible
aquí está el fragmento de tarea
- name: Create output file
blockinfile:
block: |
Some text\tmore text
path: '{{ playbook_dir }}/output.txt'
create: true
SALIDA DE CORRIENTE
# BEGIN ANSIBLE MANAGED BLOCK
Some text\tmore text
# END ANSIBLE MANAGED BLOCK
DESEADO
# BEGIN ANSIBLE MANAGED BLOCK
Some text more text
# END ANSIBLE MANAGED BLOCK
Respuesta1
Los bloques YAML conservan TAB. Tienes que usar un editor que no reemplace TAB con espacios. solíavien el siguiente ejemplo. El valor destr2son espacios cerrados con '0'. El valor destr3Hay 2 TAB(s) cerradas con '0' (copiar y pegar aquí eliminó las TAB, por supuesto).
- hosts: localhost
vars:
str1: |
01234567890
str2: |
0 0
str3: |
0 0
tasks:
- debug:
msg:
str1 {{ str1|length }} {{ str1 }}
str2 {{ str2|length }} {{ str2 }}
str3 {{ str3|length }} {{ str3 }}
da resumido
msg: |-
str1 12 01234567890
str2 12 0 0
str3 5 0 0