github.com/jlmeeker/kismatic@v1.10.1-0.20180612190640-57f9005a1f1a/ansible/roles/diagnose-nodes/tasks/main.yaml (about)

     1  ---
     2    - name: "create /tmp/diagnostics-{{ diagnostics_date_time }}/{{ inventory_hostname }} directory"
     3      file:
     4        path: "/tmp/diagnostics-{{ diagnostics_date_time }}/{{ inventory_hostname }}"
     5        state: directory
     6  
     7    - name: diagnose etcd nodes
     8      shell: "{{ item.command }} > /tmp/diagnostics-{{ diagnostics_date_time }}/{{ inventory_hostname }}/{{ item.file }} 2>&1"
     9      with_items:
    10        - "{{ diagnostics.host_diagnostics }}"
    11        - "{{ diagnostics.etcd_diagnostics }}"
    12      failed_when: false # dont fail, best effort here, some commands might not work correctly
    13      when: "'etcd' in group_names"
    14      become: true
    15  
    16    - name: diagnose master nodes
    17      shell: "{{ item.command }} > /tmp/diagnostics-{{ diagnostics_date_time }}/{{ inventory_hostname }}/{{ item.file }} 2>&1"
    18      with_items:
    19        - "{{ diagnostics.host_diagnostics }}"
    20        - "{{ diagnostics.docker_diagnostics }}"
    21        - "{{ diagnostics.k8s_diagnostics }}"
    22        - "{{ diagnostics.k8s_master_diagnostics }}"
    23        - "{{ diagnostics.calico_diagnostics }}"
    24      failed_when: false # dont fail, best effort here, some commands might not work correctly
    25      when: "'master' in group_names"
    26      become: true
    27  
    28    - name: diagnose worker nodes
    29      shell: "{{ item.command }} > /tmp/diagnostics-{{ diagnostics_date_time }}/{{ inventory_hostname }}/{{ item.file }} 2>&1"
    30      with_items:
    31        - "{{ diagnostics.host_diagnostics }}"
    32        - "{{ diagnostics.docker_diagnostics }}"
    33        - "{{ diagnostics.k8s_diagnostics }}"
    34        - "{{ diagnostics.k8s_worker_diagnostics }}"
    35        - "{{ diagnostics.calico_diagnostics }}"
    36      failed_when: false # dont fail, best effort here, some commands might not work correctly
    37      when: "'worker' in group_names or 'ingress' in group_names or 'storage' in group_names"
    38      become: true
    39  
    40    - name: archive diagnostics directory
    41      shell: "tar -zcvf /tmp/diagnostics-{{ inventory_hostname }}.tar.gz -C /tmp/diagnostics-{{ diagnostics_date_time }} . && chmod 666 /tmp/diagnostics-{{ inventory_hostname }}.tar.gz"
    42      become: true
    43  
    44    - name: "copy diagnostics to local directory in {{ diagnostics_dir }}"
    45      become: false # If this is not set, the module logs the contents of the file. ref: http://docs.ansible.com/ansible/fetch_module.html
    46      fetch:
    47        src: "/tmp/diagnostics-{{ inventory_hostname }}.tar.gz"
    48        dest: "{{ diagnostics_dir }}/"
    49        fail_on_missing: yes
    50        flat: yes