Skip to content

[ansible-plugin] back port stdout callback plugin 'yaml' from ansible2.5#1005

Merged
yxieca merged 1 commit intosonic-net:masterfrom
dawnbeauty:yaml-cb
Jul 18, 2019
Merged

[ansible-plugin] back port stdout callback plugin 'yaml' from ansible2.5#1005
yxieca merged 1 commit intosonic-net:masterfrom
dawnbeauty:yaml-cb

Conversation

@dawnbeauty
Copy link
Contributor

Description of PR

With this plugin yaml, we could get pretty-printed stdout of ansible-playbook.
And don't need to put debug everywhere.

Summary:

  • Adding the ability to use yaml plugin with stdout content

Signed-off-by: Zhiqian Wu [email protected]

Type of change

  • [] Bug fix
  • Testbed and Framework(new/improvement)
  • [] Test case(new/improvement)

Approach

How did you do it?

  • Back port yaml plugin from ansible 2.5
  • Enable plugin through ansible.cfg

How to use ?

exec ansible-playbook with ANSIBLE_STDOUT_CALLBACK or set default stdout callback to yaml through ansible.cfg

E.g.

ANSIBLE_STDOUT_CALLBACK=yaml ansible-playbook -i lab -vvv --limit str-msn2700-01 test_sonic.yml -e "testcase_name=mem_check testbed_type=t0 testbed_name=vms-t1 ptf_host=10.250.0.178"

How did you verify/test it?

assume that we have a playbook include below tasks:

   - name: Get process information in syncd docker
     shell: docker exec -i syncd ps aux | grep /usr/bin/syncd
     register: ps_out
     ignore_errors: yes

   - debug: var=ps_out.stdout_lines

without yaml plugin, the stdout is like:

TASK [test : Get process information in syncd docker] **************************
task path: /var/root/sonic-mgmt-vrf/ansible/roles/test/tasks/base_sanity.yml:1
Friday 12 July 2019  08:11:23 +0000 (0:00:00.387)       0:00:10.390 *********** 
...
changed: [str-msn2700-01] => {"changed": true, "cmd": "docker exec -i syncd ps aux | grep /usr/bin/syncd", "delta": "0:00:00.226302", "end": "2019-07-12 08:11:23.601663", "invocation": {"module_args": {"_raw_params": "docker exec -i syncd ps aux | grep /usr/bin/syncd", "_uses_shell": true, "chdir": null, "creates": null, "executable": null, "removes": null, "warn": true}, "module_name": "command"}, "rc": 0, "start": "2019-07-12 08:11:23.375361", "stderr": "", "stdout": "root        16  0.0  0.0  41584  2712 pts/0    Sl   Jul11   0:00 /usr/bin/dsserve /usr/bin/syncd --diag -u -p /usr/share/sonic/hwsku/sai.profile\nroot        25 12.8  0.3 1137728 59284 pts/0   Sl   Jul11 220:24 /usr/bin/syncd --diag -u -p /usr/share/sonic/hwsku/sai.profile", "stdout_lines": ["root        16  0.0  0.0  41584  2712 pts/0    Sl   Jul11   0:00 /usr/bin/dsserve /usr/bin/syncd --diag -u -p /usr/share/sonic/hwsku/sai.profile", "root        25 12.8  0.3 1137728 59284 pts/0   Sl   Jul11 220:24 /usr/bin/syncd --diag -u -p /usr/share/sonic/hwsku/sai.profile"], "warnings": []}

TASK [test : debug] ************************************************************
task path: /var/root/sonic-mgmt-vrf/ansible/roles/test/tasks/base_sanity.yml:6
Friday 12 July 2019  08:11:23 +0000 (0:00:00.394)       0:00:10.785 *********** 
ok: [str-msn2700-01] => {
    "ps_out.stdout_lines": [
        "root        16  0.0  0.0  41584  2712 pts/0    Sl   Jul11   0:00 /usr/bin/dsserve /usr/bin/syncd --diag -u -p /usr/share/sonic/hwsku/sai.profile", 
        "root        25 12.8  0.3 1137728 59284 pts/0   Sl   Jul11 220:24 /usr/bin/syncd --diag -u -p /usr/share/sonic/hwsku/sai.profile"
    ]
}

with yaml plugin, the stdout is like:

TASK [test : Get process information in syncd docker] **************************
task path: /var/root/sonic-mgmt-vrf/ansible/roles/test/tasks/base_sanity.yml:1
Friday 12 July 2019  08:17:45 +0000 (0:00:00.389)       0:00:10.965 *********** 
...
changed: [str-msn2700-01] => changed=true 
  cmd: docker exec -i syncd ps aux | grep /usr/bin/syncd
  delta: '0:00:00.214221'
  end: '2019-07-12 08:17:46.200908'
  invocation:
    module_args:
      _raw_params: docker exec -i syncd ps aux | grep /usr/bin/syncd
      _uses_shell: true
      chdir: null
      creates: null
      executable: null
      removes: null
      warn: true
    module_name: command
  rc: 0
  start: '2019-07-12 08:17:45.986687'
  stderr: ''
  stdout: |-
    root        16  0.0  0.0  41584  2712 pts/0    Sl   Jul11   0:00 /usr/bin/dsserve /usr/bin/syncd --diag -u -p /usr/share/sonic/hwsku/sai.profile
    root        25 12.8  0.3 1137728 59284 pts/0   Sl   Jul11 221:13 /usr/bin/syncd --diag -u -p /usr/share/sonic/hwsku/sai.profile
  stdout_lines: <omitted>
  warnings: []

TASK [test : debug] ************************************************************
task path: /var/root/sonic-mgmt-vrf/ansible/roles/test/tasks/base_sanity.yml:6
Friday 12 July 2019  08:17:46 +0000 (0:00:00.368)       0:00:11.333 *********** 
ok: [str-msn2700-01] => 
  ps_out.stdout_lines:
  - root        16  0.0  0.0  41584  2712 pts/0    Sl   Jul11   0:00 /usr/bin/dsserve /usr/bin/syncd --diag -u -p /usr/share/sonic/hwsku/sai.profile
  - root        25 12.8  0.3 1137728 59284 pts/0   Sl   Jul11 221:13 /usr/bin/syncd --diag -u -p /usr/share/sonic/hwsku/sai.profile

* Adding the abblity to use yaml plugin with stdout content

Signed-off-by: Zhiqian Wu <[email protected]>
@msftclas
Copy link

msftclas commented Jul 12, 2019

CLA assistant check
All CLA requirements met.

@dawnbeauty dawnbeauty mentioned this pull request Jul 12, 2019
1 task
@lguohan lguohan requested a review from yxieca July 18, 2019 15:59
@yxieca yxieca merged commit 113a32d into sonic-net:master Jul 18, 2019
yxieca pushed a commit that referenced this pull request Jul 19, 2019
…2.5 (#1005)

* Adding the abblity to use yaml plugin with stdout content

Signed-off-by: Zhiqian Wu <[email protected]>
lguohan pushed a commit that referenced this pull request Jul 28, 2019
[pytest] adding ability to use stdout callback plugin when running ansible module
[pytest ansible_host] Support 'module_ignore_errors' option

Signed-off-by: Zhiqian Wu [email protected]

Description of PR
Summary:

- stdout callback

With stdout callback plugin, we could get pretty-printed output of ansible module results.
It is simple and convenient to read the outputs or print dict/list objects.
So i add a function dump_ansible_results to do that. 'yaml' is the default stdout callback plugin, back port from ansible 2.5 in PR #1005 , you may choose another plugin whenever calling dump_ansible_results.

- module_ignore_errors

We need to ignore errors when execute some cmds with non-zero return codes.

Signed-off-by: Zhiqian Wu <[email protected]>
@dawnbeauty dawnbeauty deleted the yaml-cb branch August 8, 2019 09:22
sdszhang pushed a commit to sdszhang/sonic-mgmt that referenced this pull request Mar 23, 2026
…#1005)

<!--
Please make sure you've read and understood our contributing guidelines;
https://github.com/sonic-net/SONiC/blob/gh-pages/CONTRIBUTING.md

Please provide following information to help code review process a bit
easier:
-->
### Description of PR
<!--
- Please include a summary of the change and which issue is fixed.
- Please also include relevant motivation and context. Where should
reviewer start? background context?
- List any dependencies that are required for this change.
-->

Summary:
Update packet verification and port handling to support portchannels
with multiple ethernet interfaces on T0 VMs in t1-f2-d10u8 topology

Manually cherry-picked from
sonic-net#22116
Fixes # (issue)

### Type of change

<!--
- Fill x for your type of change.
- e.g.
- [x] Bug fix
-->

- [ ] Bug fix
- [ ] Testbed and Framework(new/improvement)
- [ ] New Test case
    - [ ] Skipped for non-supported platforms
- [x] Test case improvement


### Back port request
- [x] 202503
- [x] 202511

### Approach
#### What is the motivation for this PR?
test_bgp_suppress_fib.py failed on t1-f2-d10u8 topo

#### How did you do it?
Update packet verification and port handling to support portchannels
with multiple ethernet interfaces

#### How did you verify/test it?
test_bgp_suppress_fib.py passed on t1-f2-d10u8 topo

#### Any platform specific information?

#### Supported testbed topology if it's a new test case?

### Documentation
<!--
(If it's a new feature, new test case)
Did you update documentation/Wiki relevant to your implementation?
Link to the wiki page?
-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants