The callback_result_format yaml indentation

Already announced community.general.yaml has been deprecated. This callback indentes the output by 2. For example, given the below dictionary

    test:
      a: [foo, bar]
      b: {x: foo, y: bar}

The debug

    - debug:
        var: test

shows

  test:
    a:
    - foo
    - bar
    b:
      x: foo
      y: bar

When I switch to the recommended

callback_result_format = yaml

the same debug shows

    test:
        a:
        - foo
        - bar
        b:
            x: foo
            y: bar

How do I configure the indentation of this output to 2?

Is this a “feature” of PyYAML and is this pull request from @bcoca the answer?

Thank you for the links. The list indentation is an important part of the story. But, no, this doesn’t answer the question. The question is: “How do I configure the indentation of this output to 2?”. (Or any other natural number.)

1 Like

There isn’t an option to figure it currently. The default callback uses the base class to dump results (without specifying an indentation), which causes the indentation to end up as 4 ansible/lib/ansible/plugins/callback/__init__.py at stable-2.18 · ansible/ansible · GitHub.

1 Like

no, that is for an indent issue with lists, - thing vs - thing.

1 Like