blob: a856cb3e04222c1e181817c3e25089aa2f0e302f [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 Williamsf1606b92018-04-23 22:31:35 -070023 - head
24 - juju
25 - openstack
26 - onos-cord
27 - onos-fabric
28 - 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 Williamsf1606b92018-04-23 22:31:35 -070036 - "arp -n"
37 - "brctl show"
38 - "cat /etc/lsb-release"
39 - "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"
50 - "sudo docker ps -a"
51 - "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:
Zack Williamsf1606b92018-04-23 22:31:35 -070062 - "juju status --format=summary"
63 - "juju status --format=tabular"
64 - "juju status --format=json"
Zack Williams2bfbbd62016-06-13 10:18:19 -070065
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 Williamsf1606b92018-04-23 22:31:35 -070073 - "glance image-list"
74 - "nova list --all-tenants"
75 - "nova host-list"
76 - "nova hypervisor-list"
77 - "keystone tenant-list"
78 - "keystone user-list"
79 - "neutron net-list"
80 - "neutron subnet-list"
81 - "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
Zack Williamsf1606b92018-04-23 22:31:35 -070092# see also the onos-diagnostic script:
93# https://github.com/opennetworkinglab/onos/blob/master/tools/package/runtime/bin/onos-diagnostics
You Wang4089f8e2017-11-16 13:31:02 -080094- name: ONOS-CORD diag collection - ONOS CLI
95 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 -070096 ignore_errors: yes
Zack Williams35624562016-08-28 17:12:26 -070097 args:
You Wang4089f8e2017-11-16 13:31:02 -080098 creates: "~/{{ diag_dir }}/onos-cord/{{ item | regex_replace('[^\\w-]', '_')}}"
Zack Williams4e5d1d22016-06-13 11:10:03 -070099 with_items:
Zack Williamsf1606b92018-04-23 22:31:35 -0700100 - "apps -s -a"
101 - "bundle:list"
102 - "cfg get"
103 - "cordvtn-networks"
104 - "cordvtn-node-check compute1"
105 - "cordvtn-nodes"
106 - "cordvtn-ports"
107 - "devices"
108 - "dhcp-list"
109 - "dhcp-relay"
110 - "feature:list"
111 - "feature:repo-list"
112 - "flows -s"
113 - "fpm-connections"
114 - "groups"
115 - "hosts"
116 - "intents"
117 - "interfaces"
118 - "links"
119 - "log:display"
120 - "masters"
121 - "mcast-host-routes"
122 - "mcast-host-show"
123 - "netcfg"
124 - "nodes"
125 - "obj-next-ids"
126 - "obj-pending-nexts"
127 - "packet-processors"
128 - "packet-requests"
129 - "ports -e"
130 - "portstats -nz"
131 - "roles"
132 - "routes"
133 - "scr:list"
134 - "sr-device-subnets"
135 - "sr-ecmp-spg"
136 - "sr-link-state"
137 - "sr-mcast-leader"
138 - "sr-mcast-next"
139 - "sr-mcast-tree"
140 - "sr-next-hops"
141 - "sr-pw-list"
142 - "sr-should-program"
143 - "summary"
Zack Williams4e5d1d22016-06-13 11:10:03 -0700144
You Wang4089f8e2017-11-16 13:31:02 -0800145- name: ONOS-FABRIC diag collection - REST API
146 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 -0800147 ignore_errors: yes
148 args:
You Wang4089f8e2017-11-16 13:31:02 -0800149 creates: "~/{{ diag_dir }}/onos-fabric/rest_{{ item | regex_replace('[^\\w-]', '_')}}"
Suchitra Vemuri23f86222017-11-14 17:12:10 -0800150 warn: False # get_url or uri can't easily redirect to a file
151 with_items:
Zack Williamsf1606b92018-04-23 22:31:35 -0700152 - "hosts"
Suchitra Vemuri23f86222017-11-14 17:12:10 -0800153
You Wang4089f8e2017-11-16 13:31:02 -0800154- name: ONOS-FABRIC diag collection - ONOS CLI
155 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 -0800156 ignore_errors: yes
157 args:
You Wang4089f8e2017-11-16 13:31:02 -0800158 creates: "~/{{ diag_dir }}/onos-fabric/{{ item | regex_replace('[^\\w-]', '_')}}"
Suchitra Vemuri23f86222017-11-14 17:12:10 -0800159 with_items:
Zack Williamsf1606b92018-04-23 22:31:35 -0700160 - "apps -s -a"
161 - "bundle:list"
162 - "cfg get"
163 - "devices"
164 - "dhcp-relay"
165 - "feature:list"
166 - "feature:repo-list"
167 - "flows -s"
168 - "fpm-connections"
169 - "groups"
170 - "hosts"
171 - "intents"
172 - "interfaces"
173 - "links"
174 - "log:display"
175 - "masters"
176 - "mcast-host-routes"
177 - "mcast-host-show"
178 - "netcfg"
179 - "nodes"
180 - "obj-next-ids"
181 - "obj-pending-nexts"
182 - "packet-processors"
183 - "packet-requests"
184 - "ports -e"
185 - "portstats -nz"
186 - "roles"
187 - "routes"
188 - "scr:list"
189 - "sr-device-subnets"
190 - "sr-ecmp-spg"
191 - "sr-link-state"
192 - "sr-mcast-leader"
193 - "sr-mcast-next"
194 - "sr-mcast-tree"
195 - "sr-next-hops"
196 - "sr-pw-list"
197 - "sr-should-program"
198 - "summary"
Suchitra Vemuri23f86222017-11-14 17:12:10 -0800199
Zack Williams682450e2016-11-19 09:04:41 -0700200- name: Docker diag collection - Find names for all running Docker containers
Zack Williams6f0d88e2018-01-13 23:04:02 -0700201 command: sudo docker ps -a --format '{{'{{'}} .Names {{'}}'}}'
Zack Williams7bf35702017-02-08 20:40:02 -0700202 ignore_errors: yes
Zack Williams682450e2016-11-19 09:04:41 -0700203 register: docker_containers
Zack Williams35624562016-08-28 17:12:26 -0700204 tags:
Zack Williams682450e2016-11-19 09:04:41 -0700205 - skip_ansible_lint # collecting docker container names
206
207- name: Docker diag collection - Collect logs from Docker containers
Zack Williams6f0d88e2018-01-13 23:04:02 -0700208 shell: "sudo docker logs {{ item }} > ~/{{ diag_dir }}/docker/{{ item | regex_replace('[^\\w-]', '_')}}.logs 2>&1"
Zack Williams7bf35702017-02-08 20:40:02 -0700209 ignore_errors: yes
Zack Williams682450e2016-11-19 09:04:41 -0700210 args:
Zack Williams6f0d88e2018-01-13 23:04:02 -0700211 creates: "~/{{ diag_dir }}/docker/{{ item | regex_replace('[^\\w-]', '_')}}.logs"
Zack Williams7bf35702017-02-08 20:40:02 -0700212 with_items: "{{ docker_containers.stdout_lines }}"
Zack Williams682450e2016-11-19 09:04:41 -0700213 tags:
214 - skip_ansible_lint # ansible-lint interprets the \n incorrectly
215
Zack Williams6f0d88e2018-01-13 23:04:02 -0700216- name: Docker diag collection - inspect Docker containers
217 shell: "sudo docker inspect {{ item }} > ~/{{ diag_dir }}/docker/{{ item | regex_replace('[^\\w-]', '_')}}.inspect 2>&1"
218 ignore_errors: yes
219 args:
220 creates: "~/{{ diag_dir }}/docker/{{ item | regex_replace('[^\\w-]', '_')}}.inspect"
221 with_items: "{{ docker_containers.stdout_lines }}"
222 tags:
223 - skip_ansible_lint # ansible-lint interprets the \n incorrectly
224
225# much cleaner to use !unsafe to avoid j2 parsing of golang {{ and }} templates
226# but ansible-lint doesn't support it: https://github.com/willthames/ansible-lint/issues/291
227- name: Docker diag collection - Collect memory and CPU stats from docker containers
228 shell: "sudo docker stats --no-stream --format \"table {{'{{'}}.Name{{'}}'}}\t{{'{{'}}.Container{{'}}'}}\t{{'{{'}}.CPUPerc{{'}}'}}\t{{'{{'}}.MemUsage{{'}}'}}\t{{'{{'}}.MemPerc{{'}}'}}\" > ~/{{ diag_dir }}/docker/stats 2>&1"
229 ignore_errors: yes
230 args:
231 creates: "~/{{ diag_dir }}/docker/stats"
232