RedHatQE / teflo

Teflo is a standalone orchestration software that controls the flow of a set of testing scenarios, allowing users to provision machines, deploy software, execute tests against them and manage generated artifacts and report results.
https://teflo.readthedocs.io/en/latest/
GNU General Public License v3.0
14 stars 16 forks source link

CCITCARBON-406 Teflo fails to preserve whitespace when dumping ansible output #200

Closed guyyaakov1 closed 2 years ago

shay6 commented 2 years ago

LGTM this is the output:

2022-02-17 18:44:28,728 INFO TASK [Gathering Facts] *********************************************************
2022-02-17 18:44:29,672 INFO ok: [127.0.0.1]
2022-02-17 18:44:29,691 INFO 
2022-02-17 18:44:29,691 INFO TASK [debug] *******************************************************************
2022-02-17 18:44:29,703 INFO ok: [127.0.0.1] =>
2022-02-17 18:44:29,703 INFO   msg:
2022-02-17 18:44:29,704 INFO     cont:
2022-02-17 18:44:29,704 INFO       annotations: 321
2022-02-17 18:44:29,704 INFO       apiVersion: vSS1
2022-02-17 18:44:29,704 INFO       kind: Pod
2022-02-17 18:44:29,704 INFO       metadata: 123
2022-02-17 18:44:29,721 INFO 
2022-02-17 18:44:29,721 INFO PLAY RECAP *********************************************************************
2022-02-17 18:44:29,721 INFO 127.0.0.1                  : ok=2    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
guyyaakov1 commented 2 years ago

Changed func strip() to rstrip() The rstip function ignore the whitespace at the beginning of a string. The tests files:

-s test_cli_json.yml


name: var_eg
description: ""

provision:
  - name: Laptop
    groups: static-dummy
    ip_address: 127.0.0.1
    ansible_params:
      ansible_connection: local

orchestrate:

  - name: example
    description: ...
    orchestrator: ansible
    hosts: localhost
    ansible_playbook:
      name: ansible/example.yml
    ansible_options:
      extra_vars:
        file: ['variable_100.yml']

ansible/example.yml

- name: Example playbook
  hosts: localhost
  connection: local
  tasks:
    - debug:
        msg: "{{ pods }}"

variable_100.yml

---
pods: 
   cont:
      apiVersion: vSS1
      kind: Pod
      metadata: 123
      annotations: 321

ansible.cfg

[defaults]
stdout_callback = yaml
bin_ansible_callbacks = True

Teflo Output:


2022-02-21 11:20:04,270 INFO [teflo.ansible_helpers.exec_local_cmd_pipe:569] TASK [debug] *******************************************************************
2022-02-21 11:20:04,270 INFO [teflo.ansible_helpers.exec_local_cmd_pipe:569] task path: /home/gyaakov/Work/test_var_json-20220109T112846Z-001/test_var_json/ansible/example.yml:8
2022-02-21 11:20:04,337 INFO [teflo.ansible_helpers.exec_local_cmd_pipe:569] ok: [127.0.0.1] =>
2022-02-21 11:20:04,338 INFO [teflo.ansible_helpers.exec_local_cmd_pipe:569]   msg:
2022-02-21 11:20:04,338 INFO [teflo.ansible_helpers.exec_local_cmd_pipe:569]     cont:
2022-02-21 11:20:04,338 INFO [teflo.ansible_helpers.exec_local_cmd_pipe:569]       annotations: 321
2022-02-21 11:20:04,338 INFO [teflo.ansible_helpers.exec_local_cmd_pipe:569]       apiVersion: vSS1
2022-02-21 11:20:04,338 INFO [teflo.ansible_helpers.exec_local_cmd_pipe:569]       kind: Pod
2022-02-21 11:20:04,338 INFO [teflo.ansible_helpers.exec_local_cmd_pipe:569]       metadata: 123
2022-02-21 11:20:04,374 INFO [teflo.ansible_helpers.exec_local_cmd_pipe:569] META: ran handlers
2022-02-21 11:20:04,412 INFO [teflo.ansible_helpers.exec_local_cmd_pipe:569] META: ran handlers
2022-02-21 11:20:04,414 INFO [teflo.ansible_helpers.exec_local_cmd_pipe:569] 
2022-02-21 11:20:04,415 INFO [teflo.ansible_helpers.exec_local_cmd_pipe:569] PLAY RECAP *********************************************************************
2022-02-21 11:20:04,415 INFO [teflo.ansible_helpers.exec_local_cmd_pipe:569] 127.0.0.1                  : ok=2    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
``