usando guias dentro do bloco para o módulo ansible blockinfile

usando guias dentro do bloco para o módulo ansible blockinfile

Quero gerar algum texto com tabulação como separador usando ansible

aqui está o trecho da tarefa

- name: Create output file
  blockinfile:
    block: |
      Some text\tmore text
    path: '{{ playbook_dir }}/output.txt'
    create: true

SAÍDA ATUAL

# BEGIN ANSIBLE MANAGED BLOCK
Some text\tmore text
# END ANSIBLE MANAGED BLOCK

DESEJADO

# BEGIN ANSIBLE MANAGED BLOCK
Some text   more text
# END ANSIBLE MANAGED BLOCK

Responder1

Os blocos YAML preservam TAB. Você precisa usar um editor que não substitua TAB por espaços. eu useivino exemplo abaixo. O valor destr2são espaços fechados com '0'. O valor destr3são 2 TAB(s) fechadas com '0' (copiar e colar aqui removeu a(s) TAB(s), é claro).

- 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 }}

dá resumido

  msg: |-
    str1 12 01234567890
    str2 12 0         0
    str3 5 0               0

informação relacionada