| --- |
| # Copyright 2017-present Open Networking Foundation |
| # |
| # Licensed under the Apache License, Version 2.0 (the "License"); |
| # you may not use this file except in compliance with the License. |
| # You may obtain a copy of the License at |
| # |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| # See the License for the specific language governing permissions and |
| # limitations under the License. |
| |
| # head-diag/tasks/main.yml |
| |
| - name: Create diag_dir subdirs |
| file: |
| dest: "~/{{ diag_dir }}/{{ item }}" |
| state: directory |
| with_items: |
| - head |
| - juju |
| - openstack |
| - onos-cord |
| - onos-fabric |
| - docker |
| |
| - name: Head node diag collection |
| shell: "{{ item }} > ~/{{ diag_dir }}/head/{{ item | regex_replace('[^\\w-]', '_')}}" |
| ignore_errors: yes |
| args: |
| creates: "~/{{ diag_dir }}/head/{{ item | regex_replace('[^\\w-]', '_')}}" |
| with_items: |
| - "arp -n" |
| - "brctl show" |
| - "cat /etc/lsb-release" |
| - "cat /etc/resolv.conf" |
| - "date -u" |
| - "df -k" |
| - "free" |
| - "ifconfig -a" |
| - "ip addr list" |
| - "ip link list" |
| - "ip neighbor" |
| - "ip route" |
| - "ps aux" |
| - "route -n" |
| - "sudo docker ps -a" |
| - "sudo iptables -S" |
| - "sudo iptables -t nat -S" |
| - "sudo lxc list" |
| - "sudo virsh list" |
| |
| - name: Juju diag collection |
| shell: "{{ item }} > ~/{{ diag_dir }}/juju/{{ item | regex_replace('[^\\w-]', '_')}}" |
| ignore_errors: yes |
| args: |
| creates: "~/{{ diag_dir }}/juju/{{ item | regex_replace('[^\\w-]', '_')}}" |
| with_items: |
| - "juju status --format=summary" |
| - "juju status --format=tabular" |
| - "juju status --format=json" |
| |
| - name: OpenStack diag collection |
| shell: "source /opt/cord_profile/admin-openrc.sh && {{ item }} > ~/{{ diag_dir }}/openstack/{{ item | regex_replace('[^\\w-]', '_')}}" |
| ignore_errors: yes |
| args: |
| executable: "/bin/bash" |
| creates: "~/{{ diag_dir }}/openstack/{{ item | regex_replace('[^\\w-]', '_')}}" |
| with_items: |
| - "glance image-list" |
| - "nova list --all-tenants" |
| - "nova host-list" |
| - "nova hypervisor-list" |
| - "keystone tenant-list" |
| - "keystone user-list" |
| - "neutron net-list" |
| - "neutron subnet-list" |
| - "neutron port-list" |
| |
| - name: ONOS-CORD diag collection - REST API |
| 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-]', '_') }}" |
| ignore_errors: yes |
| args: |
| creates: "~/{{ diag_dir }}/onos-cord/rest_{{ item | regex_replace('[^\\w-]', '_')}}" |
| warn: False # get_url or uri can't easily redirect to a file |
| with_items: |
| - "hosts" |
| |
| - name: ONOS-CORD diag collection - ONOS CLI |
| shell: "sshpass -p 'karaf' ssh -p 8102 karaf@onos-cord {{ item }} > ~/{{ diag_dir }}/onos-cord/{{ item | regex_replace('[^\\w-]', '_') }}" |
| ignore_errors: yes |
| args: |
| creates: "~/{{ diag_dir }}/onos-cord/{{ item | regex_replace('[^\\w-]', '_')}}" |
| with_items: |
| - "apps -s -a" |
| - "bundle:list" |
| - "cordvtn-node-check compute1" |
| - "cordvtn-nodes" |
| - "cordvtn-networks" |
| - "cordvtn-ports" |
| - "dhcp-list" |
| - "devices" |
| - "flows" |
| - "hosts" |
| - "log:display" |
| - "nodes" |
| - "netcfg" |
| - "ports" |
| - "summary" |
| |
| - name: ONOS-FABRIC diag collection - REST API |
| 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-]', '_') }}" |
| ignore_errors: yes |
| args: |
| creates: "~/{{ diag_dir }}/onos-fabric/rest_{{ item | regex_replace('[^\\w-]', '_')}}" |
| warn: False # get_url or uri can't easily redirect to a file |
| with_items: |
| - "hosts" |
| |
| - name: ONOS-FABRIC diag collection - ONOS CLI |
| shell: "sshpass -p 'karaf' ssh -p 8101 karaf@onos-fabric {{ item }} > ~/{{ diag_dir }}/onos-fabric/{{ item | regex_replace('[^\\w-]', '_') }}" |
| ignore_errors: yes |
| args: |
| creates: "~/{{ diag_dir }}/onos-fabric/{{ item | regex_replace('[^\\w-]', '_')}}" |
| with_items: |
| - "apps -s -a" |
| - "bundle:list" |
| - "devices" |
| - "flows" |
| - "hosts" |
| - "log:display" |
| - "nodes" |
| - "netcfg" |
| - "ports" |
| - "summary" |
| - "links" |
| - "sr-ecmp-spg" |
| - "sr-next-hops" |
| |
| - name: Docker diag collection - Find names for all running Docker containers |
| command: sudo docker ps -a --format '{{'{{'}} .Names {{'}}'}}' |
| ignore_errors: yes |
| register: docker_containers |
| tags: |
| - skip_ansible_lint # collecting docker container names |
| |
| - name: Docker diag collection - Collect logs from Docker containers |
| shell: "sudo docker logs {{ item }} > ~/{{ diag_dir }}/docker/{{ item | regex_replace('[^\\w-]', '_')}}.logs 2>&1" |
| ignore_errors: yes |
| args: |
| creates: "~/{{ diag_dir }}/docker/{{ item | regex_replace('[^\\w-]', '_')}}.logs" |
| with_items: "{{ docker_containers.stdout_lines }}" |
| tags: |
| - skip_ansible_lint # ansible-lint interprets the \n incorrectly |
| |
| - name: Docker diag collection - inspect Docker containers |
| shell: "sudo docker inspect {{ item }} > ~/{{ diag_dir }}/docker/{{ item | regex_replace('[^\\w-]', '_')}}.inspect 2>&1" |
| ignore_errors: yes |
| args: |
| creates: "~/{{ diag_dir }}/docker/{{ item | regex_replace('[^\\w-]', '_')}}.inspect" |
| with_items: "{{ docker_containers.stdout_lines }}" |
| tags: |
| - skip_ansible_lint # ansible-lint interprets the \n incorrectly |
| |
| # much cleaner to use !unsafe to avoid j2 parsing of golang {{ and }} templates |
| # but ansible-lint doesn't support it: https://github.com/willthames/ansible-lint/issues/291 |
| - name: Docker diag collection - Collect memory and CPU stats from docker containers |
| shell: "sudo docker stats --no-stream --format \"table {{'{{'}}.Name{{'}}'}}\t{{'{{'}}.Container{{'}}'}}\t{{'{{'}}.CPUPerc{{'}}'}}\t{{'{{'}}.MemUsage{{'}}'}}\t{{'{{'}}.MemPerc{{'}}'}}\" > ~/{{ diag_dir }}/docker/stats 2>&1" |
| ignore_errors: yes |
| args: |
| creates: "~/{{ diag_dir }}/docker/stats" |
| |