| # Licensed to the Apache Software Foundation (ASF) under one or more contributor |
| # license agreements; and to You under the Apache License, Version 2.0. |
| --- |
| # 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" |
| |
| - 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"; 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 |