| # |
| # Licensed to the Apache Software Foundation (ASF) under one or more |
| # contributor license agreements. See the NOTICE file distributed with |
| # this work for additional information regarding copyright ownership. |
| # The ASF licenses this file to You 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. |
| # |
| --- |
| # This playbook is used for utilities around logs |
| |
| - import_playbook: properties.yml |
| |
| - hosts: ansible |
| tasks: |
| - name: remove "logs" folder |
| file: path="{{ openwhisk_home }}/logs" state=absent |
| - name: create "logs" folder |
| file: path="{{ openwhisk_home }}/logs" state=directory |
| - name: dump entity views |
| local_action: shell "{{ openwhisk_home }}/bin/wskadmin" db get whisks --docs --view whisks.v2.1.0/{{ item }} | tail -n +2 > "{{ openwhisk_home }}/logs/db-{{ item }}.log" |
| with_items: |
| - actions |
| - triggers |
| - rules |
| - packages |
| when: "'db' not in exclude_logs_from" |
| - name: dump activations and subjects database |
| local_action: shell "{{ openwhisk_home }}/bin/wskadmin" db get {{ item }} --docs | tail -n +2 > "{{ openwhisk_home }}/logs/db-{{ item }}.log" |
| with_items: |
| - activations |
| - subjects |
| when: "'db' not in exclude_logs_from" |
| - name: create "test reports" folder |
| file: path="{{ openwhisk_home }}/logs/test-reports" state=directory |
| - name: collect test reports |
| local_action: shell cp -r "{{ openwhisk_home }}/tests/build/{{ item }}" "{{ openwhisk_home }}/logs/test-reports/" |
| with_items: |
| - reports |
| - test-results |
| ignore_errors: true |
| when: "'tests' not in exclude_logs_from" |
| - name: create "perf reports" folder |
| file: path="{{ openwhisk_home }}/logs/perf-reports" state=directory |
| - name: collect perf logs |
| local_action: shell cp "{{ openwhisk_home }}/tests/performance/gatling_tests/build/gatling.log" "{{ openwhisk_home }}/logs/perf-reports/" |
| ignore_errors: true |
| |
| - hosts: all:!ansible |
| serial: 1 |
| tasks: |
| - name: init var docker_host_flag |
| set_fact: |
| docker_host_flag: "" |
| - name: set host flag when using docker remote API |
| set_fact: |
| docker_host_flag: "--host tcp://{{ ansible_host }}:{{ docker.port }}" |
| when: environmentInformation.type != "local" |
| - name: get all docker containers |
| local_action: shell docker {{ docker_host_flag }} ps -a --format="{% raw %}{{.Names}}{% endraw %}" |
| register: container_names |
| - name: get logs from all containers |
| local_action: shell docker {{ docker_host_flag }} logs {{ item }} > "{{ openwhisk_home }}/logs/{{ item }}.log" 2>&1; exit 0 |
| with_items: "{{ container_names.stdout_lines | difference('whisk_docker_registry') }}" |
| when: "'docker' not in exclude_logs_from" |
| - name: workaround to make synchronize work |
| set_fact: |
| ansible_ssh_private_key_file: "{{ ansible_ssh_private_key_file }}" |
| when: ansible_ssh_private_key_file is defined |
| - name: fetch logs from all machines |
| synchronize: src="{{ whisk_logs_dir }}/" dest="{{ openwhisk_home }}/logs" mode=pull |
| when: "'machine' not in exclude_logs_from" |
| ignore_errors: true |