Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions ansible/roles/test/tasks/check_testbed_interfaces.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
- block:
- name: Gathering lab graph facts about the device
conn_graph_facts: host={{ inventory_hostname }}
connection: local

- name: Fanout hostname
set_fact: fanout_switch={{ device_conn['Ethernet0']['peerdevice'] }}

- name: Check Fanout interfaces
local_action: shell ansible-playbook -i lab fanout.yml -l {{ fanout_switch }} --tags check_interfaces_status
ignore_errors: yes
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where the output does go?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All gathered info goes to the execution console, where it will be extracted if needed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we save the output into the variable and output it as

debug: var: output.stdout_lines

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, it has register/debug of output:
When interfaces.yml fails,
it calls check_testbed_interfaces.yml with check_fanout: true

check_testbed_interface.yml plays another playbook - fanout.yml with tag check_interfaces_status:
local_action: shell ansible-playbook -i lab fanout.yml -l {{ fanout_switch }} --tags check_interfaces_status
which in turns calls fanout main.yml
which contains our custom block (which was not upstreamed):

 ###################################################################
 # Check Fanout interfaces status                                  #
 ###################################################################
- block:
  - name: Check Fanout interfaces status
    action: apswitch template=roles/fanout/templates/mlnx_interfaces_status.j2
    connection: switch
    register: fanout_interfaces
    args:
      login: "{{ switch_login['MLNX-OS'] }}"

  - debug:
      msg: "{{ fanout_interfaces.stdout.split('\n') }}"

  when: peer_hwsku == "MLNX-OS"
  tags: check_interfaces_status

Here we expect any team may have their own block relevant to specific vendor, called by
tags: check_interfaces_status

That is why you might have not got any information when you ran the test.


when:
- check_fanout is defined

- block:
- name: Get Portchannel status
shell: show interfaces portchannel
register: portchannel_status
ignore_errors: yes

- name: Get teamd dump
shell: teamdctl '{{ item }}' state dump
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where the output does go?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All gathered info goes to the execution console, where it will be extracted if needed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we save the output into the variable and output it as

debug: var: output.stdout_lines

Copy link
Copy Markdown
Contributor Author

@romankachur-mlnx romankachur-mlnx Feb 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, its simple imrovement, but will be done as new PR (this source branch doesn't exist anymore).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To handle this case, I opened another PR, that includes this changes as well
#815

with_items: "{{ minigraph_portchannels }}"
ignore_errors: yes
when:
- minigraph_portchannels is defined

- name: Define testbed_name when not obtained
set_fact:
testbed_name: "{{ inventory_hostname + '-' + topo }}"
when: testbed_name is not defined

- name: Gathering testbed information
test_facts: testbed_name="{{ testbed_name }}"
connection: local
ignore_errors: yes

- name: Gather vm list from Testbed server
local_action: shell ansible-playbook testbed_vm_status.yml -i veos -l "{{ testbed_facts['server'] }}"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where the output does go?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All gathered info goes to the execution console, where it will be extracted if needed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we save the output into the variable and output it as

debug: var: output.stdout_lines

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is the same explanation as in the first conversation.

When interfaces.yml fails,
it calls check_testbed_interfaces.yml with check_vms: true

check_testbed_interface.yml plays another playbook - testbed_vm_status.yml:
local_action: shell ansible-playbook testbed_vm_status.yml -i veos -l "{{ testbed_facts['server'] }}"

testbed_vm_status.yml has register/debug of output

- hosts: servers:&vm_host
  tasks:
  - name: Get VM statuses from Testbed server
    shell: virsh list
    register: virsh_list
  - name: Show VM statuses
    debug: msg="{{ virsh_list['stdout_lines'] }}"

but it only will be shown in verbose mode -vvvvv of the outer playbook:

ignore_errors: yes

- set_fact:
vms: "{{ minigraph_devices }}"
peer_hwsku: 'Arista-VM'

- name: Gather Port-Channel status from VMs
action: apswitch template=roles/vm_set/templates/show_int_portchannel_status.j2
args:
host: "{{ vms[item]['mgmt_addr'] }}"
login: "{{ switch_login[hwsku_map[peer_hwsku]] }}"
connection: switch
ignore_errors: yes
when: vms["{{ item }}"]['hwsku'] == 'Arista-VM'
with_items: vms
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where the output does go?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All gathered info goes to the execution console, where it will be extracted if needed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we save the output into the variable and output it as

debug: var: output.stdout_lines

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, its simple imrovement, but will be done as new PR (this source brunch doesn't exist anymore).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To handle this case, I opened another PR, that includes this changes as well
#815


when: check_vms is defined
24 changes: 19 additions & 5 deletions ansible/roles/test/tasks/interface.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,26 @@
- debug: msg="Found link down ports {{ansible_interface_link_down_ports}}"
when: ansible_interface_link_down_ports | length > 0

- name: Verify interfaces are up correctly
assert: { that: "{{ ansible_interface_link_down_ports | length }} == 0" }
- block:
- name: Verify interfaces are up correctly
assert: { that: "{{ ansible_interface_link_down_ports | length }} == 0" }
rescue:
- include: check_testbed_interfaces.yml
vars:
check_fanout: true
- fail: msg="Not all Interfaces are up"

- name: Verify port channel interfaces are up correctly
assert: { that: "'{{ ansible_interface_facts[item]['active'] }}' == 'True'" }
with_items: "{{ minigraph_portchannels.keys() }}"
- block:
- name: Verify port channel interfaces are up correctly
assert: { that: "'{{ ansible_interface_facts[item]['active'] }}' == 'True'" }
with_items: "{{ minigraph_portchannels.keys() }}"

rescue:
- include: check_testbed_interfaces.yml
vars:
check_vms: true
- fail: msg="Not all PortChannels are up '{{ portchannel_status['stdout_lines'] }}' "
when: portchannel_status is defined

- name: Verify VLAN interfaces are up correctly
assert: { that: "'{{ ansible_interface_facts[item]['active'] }}' == 'True'" }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
show interfaces Port-Channel 1-$ status
9 changes: 9 additions & 0 deletions ansible/testbed_vm_status.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Example:
# ansible-playbook testbed_vm_status.yml -i veos -l server_1
- hosts: servers:&vm_host
tasks:
- name: Get VM statuses from Testbed server
shell: virsh list
register: virsh_list
- name: Show VM statuses
debug: msg="{{ virsh_list['stdout_lines'] }}"