-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Story #14016: Add troubleshoot playbook for VitamUI
- Loading branch information
Abderrahman Bouayad
committed
Jan 15, 2025
1 parent
63979de
commit 4a9cf66
Showing
9 changed files
with
341 additions
and
0 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
deployment/ansible-vitamui-exploitation/roles/end_troubleshoot/tasks/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
- name: archive troubleshoot | ||
archive: | ||
path: "{{ inventory_dir }}/troubleshoot/" | ||
dest: "{{ inventory_dir }}/troubleshoot_{{ ansible_date_time.date }}T{{ ansible_date_time.time }}-{{ log_files_age }}d_{{ vitamui_site_name }}.zip" | ||
remove: yes | ||
format: zip | ||
delegate_to: localhost | ||
run_once: true | ||
|
||
- name: remove troubleshoot directory | ||
file: | ||
path: "{{ inventory_dir }}/troubleshoot/" | ||
state: absent | ||
delegate_to: localhost | ||
run_once: true | ||
|
||
- name: display post install message | ||
debug: | ||
msg: "Please send generated {{ inventory_dir }}/troubleshoot_{{ ansible_date_time.date }}T{{ ansible_date_time.time }}-{{ log_files_age }}d_{{ vitamui_site_name }}.zip file by mail to Vitamui support" | ||
delegate_to: localhost | ||
run_once: true |
16 changes: 16 additions & 0 deletions
16
deployment/ansible-vitamui-exploitation/roles/gather_host/tasks/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
|
||
- name: gather facts | ||
setup: | ||
register: faits | ||
|
||
# - name: test | ||
# debug: | ||
# msg: "{{ faits }}" | ||
|
||
- name: get back facts | ||
copy: | ||
content: "{{ faits }}" | ||
dest: "{{ inventory_dir }}/troubleshoot/{{ inventory_hostname }}/facts.json" | ||
mode: 0775 | ||
delegate_to: localhost |
33 changes: 33 additions & 0 deletions
33
deployment/ansible-vitamui-exploitation/roles/init_troubleshoot/tasks/mail.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
--- | ||
|
||
- name: init troubleshoot directories | ||
file: | ||
path: "{{ inventory_dir }}/troubleshoot/{{ inventory_hostname }}/" | ||
state: directory | ||
mode: 0777 | ||
delegate_to: localhost | ||
|
||
# If sync_type == 'rsync' | ||
- block: | ||
|
||
- name: ensure rsync package is installed for synchronize module | ||
package: | ||
name: rsync | ||
state: present | ||
register: result | ||
retries: "{{ packages_install_retries_number }}" | ||
until: result is succeeded | ||
delay: "{{ packages_install_retries_delay }}" | ||
|
||
- name: ensure rsync is installed locally for synchronize module | ||
package: | ||
name: rsync | ||
state: present | ||
register: result | ||
retries: "{{ packages_install_retries_number }}" | ||
until: result is succeeded | ||
delay: "{{ packages_install_retries_delay }}" | ||
run_once: true | ||
delegate_to: localhost | ||
|
||
when: sync_type | default('fetch') | lower == 'rsync' |
7 changes: 7 additions & 0 deletions
7
deployment/ansible-vitamui-exploitation/roles/resolvconf/tasks/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
|
||
- name: get back /etc/resolv.conf | ||
fetch: | ||
src: "/etc/resolv.conf" | ||
dest: "{{ inventory_dir }}/troubleshoot/{{ inventory_hostname }}/resolv.conf" | ||
flat: yes |
20 changes: 20 additions & 0 deletions
20
deployment/ansible-vitamui-exploitation/roles/tree_deployment/tasks/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
|
||
- name: Install tree package | ||
ignore_errors: true | ||
become: true | ||
package: | ||
name: tree | ||
state: present | ||
register: result | ||
retries: "{{ packages_install_retries_number }}" | ||
until: result is succeeded | ||
delay: "{{ packages_install_retries_delay }}" | ||
delegate_to: localhost | ||
run_once: true | ||
|
||
- name: list all files | ||
ignore_errors: true | ||
shell: tree -a ../../ > {{ inventory_dir }}/troubleshoot/listing_ansible.txt | ||
delegate_to: localhost | ||
run_once: true |
45 changes: 45 additions & 0 deletions
45
deployment/ansible-vitamui-exploitation/roles/vitamui_log_files/tasks/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
--- | ||
|
||
- name: list files from {{ vitamui_defaults.folder.root_path | default('/vitamui') }}/log/{{ component_name }} | ||
find: | ||
paths: "{{ vitamui_defaults.folder.root_path | default('/vitamui') }}/log/{{ component_name }}" | ||
age: "-{{ age }}d" | ||
recurse: no # no subdir | ||
file_type: file | ||
excludes: "java_pid*,{{ excludes | default('') }}" | ||
register: path_files | ||
|
||
# Run the rest only if there is files to get | ||
- block: | ||
|
||
- name: create list of files | ||
set_fact: fichier="{{ item.path }}" | ||
with_items: "{{ path_files.files }}" | ||
register: filespath | ||
|
||
- name: Create a temp zip archive from {{ component_name }} | ||
archive: | ||
path: "{{ filespath.results| map(attribute='ansible_facts.fichier') | list }}" | ||
dest: "{{ vitamui_defaults.folder.root_path | default('/vitamui') }}/tmp/{{ component_name }}/{{ component_name }}.zip" | ||
format: zip | ||
|
||
- name: fetch zip file from {{ component_name }} with rsync method | ||
synchronize: | ||
mode: pull | ||
src: "{{ vitamui_defaults.folder.root_path | default('/vitamui') }}/tmp/{{ component_name }}/{{ component_name }}.zip" | ||
dest: "{{ inventory_dir }}/troubleshoot/{{ inventory_hostname }}/{{ component_name }}/" | ||
when: sync_type | default('fetch') | lower == 'rsync' | ||
|
||
- name: fetch zip file from {{ component_name }} with fetch method | ||
fetch: | ||
src: "{{ vitamui_defaults.folder.root_path | default('/vitamui') }}/tmp/{{ component_name }}/{{ component_name }}.zip" | ||
dest: "{{ inventory_dir }}/troubleshoot/{{ inventory_hostname }}/{{ component_name }}/{{ component_name }}.zip" | ||
flat: yes | ||
when: sync_type | default('fetch') | lower == 'fetch' | ||
|
||
- name: remove temp zip file on host | ||
file: | ||
path: "{{ vitamui_defaults.folder.root_path | default('/vitamui') }}/tmp/{{ component_name }}/{{ component_name }}.zip" | ||
state: absent | ||
|
||
when: path_files is defined and path_files.matched > 0 |
182 changes: 182 additions & 0 deletions
182
deployment/ansible-vitamui-exploitation/troubleshoot.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,182 @@ | ||
--- | ||
# Example: ansible-vitamui-exploitation/troubleshoot.yml -e 'confirmation=YES log_files_age=2' | ||
# Optional parameters: -e 'sync_type=rsync get_crt=yes excludes=gc*,access*' | ||
|
||
# Confirm launching this playbook | ||
- hosts: localhost | ||
any_errors_fatal: yes | ||
gather_facts: no | ||
vars_prompt: | ||
name: "confirmation" | ||
prompt: "This playbook will collect logs and other useful information to help debugging your VitamUI instance.\n\nAre you sure you want to run this playbook ?\nAnswer with 'YES'" | ||
default: "NO" | ||
private: no | ||
tasks: | ||
- name: Check Confirmation | ||
fail: msg="Playbook run confirmation failed" | ||
when: confirmation | default(false) | bool == false | ||
tags: always | ||
run_once: true | ||
|
||
- hosts: all | ||
any_errors_fatal: yes | ||
gather_facts: no | ||
vars_prompt: | ||
name: log_files_age | ||
prompt: "Type the maximum age of the files you want to retrieve (in days)" | ||
default: 2 | ||
private: no | ||
tasks: | ||
- name: Age check | ||
fail: | ||
msg: "log_files_age is not valid: {{ log_files_age }} <= 0" | ||
when: log_files_age | int <= 0 | ||
- name: Register var | ||
set_fact: | ||
log_files_age: "{{ log_files_age }}" | ||
run_once: true | ||
|
||
|
||
# Init troubleshoot | ||
- hosts: vitam | ||
gather_facts: no | ||
roles: | ||
- init_troubleshoot | ||
- resolvconf | ||
# - tree_deployment | ||
- ../../roles/check_parent_structure | ||
|
||
|
||
# fetch logs | ||
# application log | ||
|
||
- hosts: hosts_cas_server | ||
gather_facts: no | ||
ignore_errors: true | ||
roles: | ||
- vitamui_log_files | ||
vars: | ||
component_name: "{{ vitamui.cas_server.vitamui_component }}" | ||
age: "{{ log_files_age }}" | ||
|
||
- hosts: hosts_vitamui_api_gateway | ||
gather_facts: no | ||
ignore_errors: true | ||
roles: | ||
- vitamui_log_files | ||
vars: | ||
component_name: "{{ vitamui.api_gateway.vitamui_component }}" | ||
age: "{{ log_files_age }}" | ||
|
||
- hosts: hosts_vitamui_referential_external | ||
gather_facts: no | ||
ignore_errors: true | ||
roles: | ||
- vitamui_log_files | ||
vars: | ||
component_name: "{{ vitamui.referential_external.vitamui_component }}" | ||
age: "{{ log_files_age }}" | ||
|
||
- hosts: hosts_vitamui_iam_external | ||
gather_facts: no | ||
ignore_errors: true | ||
roles: | ||
- vitamui_log_files | ||
vars: | ||
component_name: "{{ vitamui.iam_external.vitamui_component }}" | ||
age: "{{ log_files_age }}" | ||
|
||
- hosts: hosts_vitamui_iam_internal | ||
gather_facts: no | ||
ignore_errors: true | ||
roles: | ||
- vitamui_log_files | ||
vars: | ||
component_name: "{{ vitamui.iam_internal.vitamui_component }}" | ||
age: "{{ log_files_age }}" | ||
|
||
- hosts: hosts_vitamui_security_internal | ||
gather_facts: no | ||
ignore_errors: true | ||
roles: | ||
- vitamui_log_files | ||
vars: | ||
component_name: "{{ vitamui.security_internal.vitamui_component }}" | ||
age: "{{ log_files_age }}" | ||
|
||
- hosts: hosts_vitamui_ingest_external | ||
gather_facts: no | ||
ignore_errors: true | ||
roles: | ||
- vitamui_log_files | ||
vars: | ||
component_name: "{{ vitamui.ingest_external.vitamui_component }}" | ||
age: "{{ log_files_age }}" | ||
|
||
- hosts: hosts_vitamui_ingest_internal | ||
gather_facts: no | ||
ignore_errors: true | ||
roles: | ||
- vitamui_log_files | ||
vars: | ||
component_name: "{{ vitamui.ingest_internal.vitamui_component }}" | ||
age: "{{ log_files_age }}" | ||
|
||
- hosts: hosts_vitamui_archive_search_external | ||
gather_facts: no | ||
ignore_errors: true | ||
roles: | ||
- vitamui_log_files | ||
vars: | ||
component_name: "{{ vitamui.archive_search_external.vitamui_component }}" | ||
age: "{{ log_files_age }}" | ||
|
||
- hosts: hosts_vitamui_archive_search_internal | ||
gather_facts: no | ||
ignore_errors: true | ||
roles: | ||
- vitamui_log_files | ||
vars: | ||
component_name: "{{ vitamui.archive_search_internal.vitamui_component }}" | ||
age: "{{ log_files_age }}" | ||
|
||
- hosts: hosts_vitamui_collect_external | ||
gather_facts: no | ||
ignore_errors: true | ||
roles: | ||
- vitamui_log_files | ||
vars: | ||
component_name: "{{ vitamui.collect_external.vitamui_component }}" | ||
age: "{{ log_files_age }}" | ||
|
||
- hosts: hosts_vitamui_collect_internal | ||
gather_facts: no | ||
ignore_errors: true | ||
roles: | ||
- vitamui_log_files | ||
vars: | ||
component_name: "{{ vitamui.collect_internal.vitamui_component }}" | ||
age: "{{ log_files_age }}" | ||
|
||
- hosts: hosts_vitamui_pastis_external | ||
gather_facts: no | ||
ignore_errors: true | ||
roles: | ||
- vitamui_log_files | ||
vars: | ||
component_name: "{{ vitamui.pastis_external.vitamui_component }}" | ||
age: "{{ log_files_age }}" | ||
|
||
|
||
# End troubleshoot | ||
|
||
#- hosts: hosts_vitamui | ||
# gather_facts: no | ||
# ignore_errors: true | ||
# roles: | ||
# - { role: get_crt_files, when: get_crt | default(false) | bool == true } | ||
|
||
- hosts: hosts_vitamui | ||
gather_facts: no | ||
roles: | ||
- end_troubleshoot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -300,3 +300,5 @@ opentracing: | |
|
||
syslog: | ||
name: filebeat # or rsyslog | ||
|
||
packages_install_retries_delay: 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
|
||
- name: check whether VITAMUI parent dir already exists | ||
stat: | ||
path: "{{ vitamui_defaults.folder.root_path }}" | ||
register: root_dir | ||
|
||
- name: fail if this VITAMUI parent dir is a symlink | ||
#shell: echo "root vitam dir is symlink" > {{ inventory_dir }}/troubleshoot/{{ inventory_hostname }}/vitam_root_dir_symlink.txt | ||
copy: | ||
content: "root vitam dir is symlink" | ||
dest: "{{ inventory_dir }}/troubleshoot/{{ inventory_hostname }}/vitam_root_dir_symlink.txt" | ||
delegate_to: localhost | ||
when: root_dir.stat.islnk is defined and root_dir.stat.islnk == "true" |