blob: 093686670a75337cff7d41bf1cf7848f69552b81 [file] [log] [blame]
Zack Williams6f0d88e2018-01-13 23:04:02 -07001---
Matteo Scandolo3896c472017-08-01 13:31:42 -07002# Copyright 2017-present Open Networking Foundation
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
Zack Williams2bfbbd62016-06-13 10:18:19 -070016# head-diag/tasks/main.yml
17
Zack Williams2bfbbd62016-06-13 10:18:19 -070018- name: Create diag_dir subdirs
19 file:
Zack Williams6f0d88e2018-01-13 23:04:02 -070020 dest: "~/{{ diag_dir }}/{{ item }}"
21 state: directory
Zack Williams2bfbbd62016-06-13 10:18:19 -070022 with_items:
Zack Williamsdc4878f2016-07-26 14:50:30 -070023 - head
Zack Williams2bfbbd62016-06-13 10:18:19 -070024 - juju
25 - openstack
You Wang4089f8e2017-11-16 13:31:02 -080026 - onos-cord
27 - onos-fabric
Zack Williams682450e2016-11-19 09:04:41 -070028 - docker
Zack Williams2bfbbd62016-06-13 10:18:19 -070029
Zack Williamsdc4878f2016-07-26 14:50:30 -070030- name: Head node diag collection
31 shell: "{{ item }} > ~/{{ diag_dir }}/head/{{ item | regex_replace('[^\\w-]', '_')}}"
Zack Williams7bf35702017-02-08 20:40:02 -070032 ignore_errors: yes
Zack Williams35624562016-08-28 17:12:26 -070033 args:
34 creates: "~/{{ diag_dir }}/head/{{ item | regex_replace('[^\\w-]', '_')}}"
Zack Williams2bfbbd62016-06-13 10:18:19 -070035 with_items:
Zack Williamscb52e5b2016-06-13 11:25:29 -070036 - "arp -n"
Zack Williams2bfbbd62016-06-13 10:18:19 -070037 - "brctl show"
Zack Williamsdc4878f2016-07-26 14:50:30 -070038 - "cat /etc/lsb-release"
Zack Williams6f0d88e2018-01-13 23:04:02 -070039 - "cat /etc/resolv.conf"
40 - "date -u"
41 - "df -k"
42 - "free"
43 - "ifconfig -a"
44 - "ip addr list"
45 - "ip link list"
46 - "ip neighbor"
47 - "ip route"
48 - "ps aux"
49 - "route -n"
Zack Williams7bf35702017-02-08 20:40:02 -070050 - "sudo docker ps -a"
Zack Williams6f0d88e2018-01-13 23:04:02 -070051 - "sudo iptables -S"
52 - "sudo iptables -t nat -S"
53 - "sudo lxc list"
54 - "sudo virsh list"
Zack Williams2bfbbd62016-06-13 10:18:19 -070055
56- name: Juju diag collection
Zack Williams04106732016-06-27 20:55:32 -070057 shell: "{{ item }} > ~/{{ diag_dir }}/juju/{{ item | regex_replace('[^\\w-]', '_')}}"
Zack Williams7bf35702017-02-08 20:40:02 -070058 ignore_errors: yes
Zack Williams35624562016-08-28 17:12:26 -070059 args:
60 creates: "~/{{ diag_dir }}/juju/{{ item | regex_replace('[^\\w-]', '_')}}"
Zack Williams2bfbbd62016-06-13 10:18:19 -070061 with_items:
62 - "juju status --format=summary"
Zack Williams7bf35702017-02-08 20:40:02 -070063 - "juju status --format=tabular"
Zack Williams2bfbbd62016-06-13 10:18:19 -070064 - "juju status --format=json"
65
66- name: OpenStack diag collection
Zack Williamsc989f262017-05-11 13:02:59 -070067 shell: "source /opt/cord_profile/admin-openrc.sh && {{ item }} > ~/{{ diag_dir }}/openstack/{{ item | regex_replace('[^\\w-]', '_')}}"
Zack Williams7bf35702017-02-08 20:40:02 -070068 ignore_errors: yes
Zack Williams2bfbbd62016-06-13 10:18:19 -070069 args:
70 executable: "/bin/bash"
Zack Williams35624562016-08-28 17:12:26 -070071 creates: "~/{{ diag_dir }}/openstack/{{ item | regex_replace('[^\\w-]', '_')}}"
Zack Williams2bfbbd62016-06-13 10:18:19 -070072 with_items:
Zack Williamsa6536462016-06-13 13:13:33 -070073 - "glance image-list"
Zack Williams2bfbbd62016-06-13 10:18:19 -070074 - "nova list --all-tenants"
Zack Williams85fd3042016-06-13 13:47:58 -070075 - "nova host-list"
Zack Williams7bf35702017-02-08 20:40:02 -070076 - "nova hypervisor-list"
Zack Williams2bfbbd62016-06-13 10:18:19 -070077 - "keystone tenant-list"
Zack Williamsa6536462016-06-13 13:13:33 -070078 - "keystone user-list"
79 - "neutron net-list"
80 - "neutron subnet-list"
Zack Williams85fd3042016-06-13 13:47:58 -070081 - "neutron port-list"
Zack Williams2bfbbd62016-06-13 10:18:19 -070082
You Wang4089f8e2017-11-16 13:31:02 -080083- name: ONOS-CORD diag collection - REST API
84 shell: "curl -X GET -u karaf:karaf http://onos-cord:8182/onos/v1/{{ item }} | python -m json.tool > ~/{{ diag_dir }}/onos-cord/rest_{{ item | regex_replace('[^\\w-]', '_') }}"
Zack Williams7bf35702017-02-08 20:40:02 -070085 ignore_errors: yes
Zack Williams35624562016-08-28 17:12:26 -070086 args:
You Wang4089f8e2017-11-16 13:31:02 -080087 creates: "~/{{ diag_dir }}/onos-cord/rest_{{ item | regex_replace('[^\\w-]', '_')}}"
Zack Williams35624562016-08-28 17:12:26 -070088 warn: False # get_url or uri can't easily redirect to a file
Zack Williams2bfbbd62016-06-13 10:18:19 -070089 with_items:
90 - "hosts"
91
You Wang4089f8e2017-11-16 13:31:02 -080092- name: ONOS-CORD diag collection - ONOS CLI
93 shell: "sshpass -p 'karaf' ssh -p 8102 karaf@onos-cord {{ item }} > ~/{{ diag_dir }}/onos-cord/{{ item | regex_replace('[^\\w-]', '_') }}"
Zack Williams7bf35702017-02-08 20:40:02 -070094 ignore_errors: yes
Zack Williams35624562016-08-28 17:12:26 -070095 args:
You Wang4089f8e2017-11-16 13:31:02 -080096 creates: "~/{{ diag_dir }}/onos-cord/{{ item | regex_replace('[^\\w-]', '_')}}"
Zack Williams4e5d1d22016-06-13 11:10:03 -070097 with_items:
Zack Williamsae17c502016-06-28 22:05:19 -070098 - "apps -s -a"
99 - "bundle:list"
Zack Williams97bbf0b2017-08-01 22:50:08 -0700100 - "cordvtn-node-check compute1"
Zack Williamsae17c502016-06-28 22:05:19 -0700101 - "cordvtn-nodes"
Zack Williams682450e2016-11-19 09:04:41 -0700102 - "cordvtn-networks"
103 - "cordvtn-ports"
Zack Williamsba7af9e2016-06-27 17:21:09 -0700104 - "dhcp-list"
Zack Williams97bbf0b2017-08-01 22:50:08 -0700105 - "devices"
Zack Williamsae17c502016-06-28 22:05:19 -0700106 - "flows"
107 - "hosts"
108 - "log:display"
109 - "nodes"
Zack Williams97bbf0b2017-08-01 22:50:08 -0700110 - "netcfg"
Zack Williamsae17c502016-06-28 22:05:19 -0700111 - "ports"
112 - "summary"
Zack Williams4e5d1d22016-06-13 11:10:03 -0700113
You Wang4089f8e2017-11-16 13:31:02 -0800114- name: ONOS-FABRIC diag collection - REST API
115 shell: "curl -X GET -u karaf:karaf http://onos-fabric:8182/onos/v1/{{ item }} | python -m json.tool > ~/{{ diag_dir }}/onos-fabric/rest_{{ item | regex_replace('[^\\w-]', '_') }}"
Suchitra Vemuri23f86222017-11-14 17:12:10 -0800116 ignore_errors: yes
117 args:
You Wang4089f8e2017-11-16 13:31:02 -0800118 creates: "~/{{ diag_dir }}/onos-fabric/rest_{{ item | regex_replace('[^\\w-]', '_')}}"
Suchitra Vemuri23f86222017-11-14 17:12:10 -0800119 warn: False # get_url or uri can't easily redirect to a file
120 with_items:
121 - "hosts"
122
You Wang4089f8e2017-11-16 13:31:02 -0800123- name: ONOS-FABRIC diag collection - ONOS CLI
124 shell: "sshpass -p 'karaf' ssh -p 8101 karaf@onos-fabric {{ item }} > ~/{{ diag_dir }}/onos-fabric/{{ item | regex_replace('[^\\w-]', '_') }}"
Suchitra Vemuri23f86222017-11-14 17:12:10 -0800125 ignore_errors: yes
126 args:
You Wang4089f8e2017-11-16 13:31:02 -0800127 creates: "~/{{ diag_dir }}/onos-fabric/{{ item | regex_replace('[^\\w-]', '_')}}"
Suchitra Vemuri23f86222017-11-14 17:12:10 -0800128 with_items:
129 - "apps -s -a"
130 - "bundle:list"
You Wang4089f8e2017-11-16 13:31:02 -0800131 - "devices"
132 - "flows"
Suchitra Vemuri23f86222017-11-14 17:12:10 -0800133 - "hosts"
134 - "log:display"
You Wang4089f8e2017-11-16 13:31:02 -0800135 - "nodes"
Suchitra Vemuri23f86222017-11-14 17:12:10 -0800136 - "netcfg"
137 - "ports"
138 - "summary"
Suchitra Vemuri15b55fc2018-01-31 14:52:37 -0800139 - "links"
140 - "sr-ecmp-spg"
141 - "sr-next-hops"
Suchitra Vemuri23f86222017-11-14 17:12:10 -0800142
Zack Williams682450e2016-11-19 09:04:41 -0700143- name: Docker diag collection - Find names for all running Docker containers
Zack Williams6f0d88e2018-01-13 23:04:02 -0700144 command: sudo docker ps -a --format '{{'{{'}} .Names {{'}}'}}'
Zack Williams7bf35702017-02-08 20:40:02 -0700145 ignore_errors: yes
Zack Williams682450e2016-11-19 09:04:41 -0700146 register: docker_containers
Zack Williams35624562016-08-28 17:12:26 -0700147 tags:
Zack Williams682450e2016-11-19 09:04:41 -0700148 - skip_ansible_lint # collecting docker container names
149
150- name: Docker diag collection - Collect logs from Docker containers
Zack Williams6f0d88e2018-01-13 23:04:02 -0700151 shell: "sudo docker logs {{ item }} > ~/{{ diag_dir }}/docker/{{ item | regex_replace('[^\\w-]', '_')}}.logs 2>&1"
Zack Williams7bf35702017-02-08 20:40:02 -0700152 ignore_errors: yes
Zack Williams682450e2016-11-19 09:04:41 -0700153 args:
Zack Williams6f0d88e2018-01-13 23:04:02 -0700154 creates: "~/{{ diag_dir }}/docker/{{ item | regex_replace('[^\\w-]', '_')}}.logs"
Zack Williams7bf35702017-02-08 20:40:02 -0700155 with_items: "{{ docker_containers.stdout_lines }}"
Zack Williams682450e2016-11-19 09:04:41 -0700156 tags:
157 - skip_ansible_lint # ansible-lint interprets the \n incorrectly
158
Zack Williams6f0d88e2018-01-13 23:04:02 -0700159- name: Docker diag collection - inspect Docker containers
160 shell: "sudo docker inspect {{ item }} > ~/{{ diag_dir }}/docker/{{ item | regex_replace('[^\\w-]', '_')}}.inspect 2>&1"
161 ignore_errors: yes
162 args:
163 creates: "~/{{ diag_dir }}/docker/{{ item | regex_replace('[^\\w-]', '_')}}.inspect"
164 with_items: "{{ docker_containers.stdout_lines }}"
165 tags:
166 - skip_ansible_lint # ansible-lint interprets the \n incorrectly
167
168# much cleaner to use !unsafe to avoid j2 parsing of golang {{ and }} templates
169# but ansible-lint doesn't support it: https://github.com/willthames/ansible-lint/issues/291
170- name: Docker diag collection - Collect memory and CPU stats from docker containers
171 shell: "sudo docker stats --no-stream --format \"table {{'{{'}}.Name{{'}}'}}\t{{'{{'}}.Container{{'}}'}}\t{{'{{'}}.CPUPerc{{'}}'}}\t{{'{{'}}.MemUsage{{'}}'}}\t{{'{{'}}.MemPerc{{'}}'}}\" > ~/{{ diag_dir }}/docker/stats 2>&1"
172 ignore_errors: yes
173 args:
174 creates: "~/{{ diag_dir }}/docker/stats"
175