-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add dagnostic role and merge glances to it
- Loading branch information
1 parent
2dfd526
commit 3502494
Showing
24 changed files
with
352 additions
and
109 deletions.
There are no files selected for viewing
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
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
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 |
---|---|---|
|
@@ -22,4 +22,4 @@ | |
force: true | ||
|
||
roles: | ||
- role: alphanodes.setup.glances | ||
- role: alphanodes.setup.diagnostic |
File renamed without changes.
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,21 @@ | ||
# Ansible Role: Diagnostic tools | ||
|
||
Setup diagnostic tools on Debian and Ubuntu servers. | ||
|
||
## Role Variables | ||
|
||
Available variables can be found in [defaults/main.yml](defaults/main.yml) | ||
|
||
## Example Playbook | ||
|
||
```yaml | ||
- hosts: all | ||
|
||
vars: | ||
diagnostic_with_btop: true | ||
diagnostic_with_glances: true | ||
diagnostic_with_htop: true | ||
|
||
roles: | ||
- alphanodes.setup.diagnostic | ||
``` |
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,23 @@ | ||
--- | ||
# defaults file for diagnostic tools | ||
|
||
diagnostic_with_atop: false | ||
diagnostic_with_bottom: false | ||
# bottom is not implemented at the moment | ||
diagnostic_with_btop: true | ||
# make sure pip is installed for glances | ||
diagnostic_with_glances: tfalse | ||
diagnostic_with_htop: false | ||
diagnostic_with_nmap: false | ||
diagnostic_with_sysstat: false | ||
|
||
diagnostic_packages: | ||
- deborphan | ||
|
||
# required a lot of packages for glances without pip (e.g. nginx) | ||
glances_with_pip: true | ||
glances_pip_packages: | ||
- glances | ||
glances_pip_venv: glances | ||
|
||
sysstat_enable_data_collecting: true |
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,26 @@ | ||
# Beware! This file is rewritten by htop when settings are changed in the interface. | ||
# The parser is also very primitive, and not human-friendly. | ||
fields=50 0 48 17 18 38 39 40 2 46 47 49 1 | ||
sort_key=111 | ||
sort_direction=1 | ||
hide_threads=1 | ||
hide_kernel_threads=1 | ||
hide_userland_threads=1 | ||
shadow_other_users=0 | ||
show_thread_names=0 | ||
show_program_path=1 | ||
highlight_base_name=0 | ||
highlight_megabytes=0 | ||
highlight_threads=0 | ||
tree_view=1 | ||
header_margin=1 | ||
detailed_cpu_time=1 | ||
cpu_count_from_zero=1 | ||
update_process_names=0 | ||
account_guest_in_cpu_meter=0 | ||
color_scheme=6 | ||
delay=15 | ||
left_meters=CPU AllCPUs | ||
left_meter_modes=2 1 | ||
right_meters=Blank Clock Memory Swap | ||
right_meter_modes=2 2 2 1 |
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
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,6 @@ | ||
--- | ||
|
||
- name: Include setup tasks | ||
ansible.builtin.import_tasks: setup.yml | ||
tags: | ||
- diagnostic |
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,50 @@ | ||
--- | ||
|
||
- name: Set facts | ||
ansible.builtin.set_fact: | ||
managing_user: "{{ ansible_user | default(ansible_env.USER) }}" | ||
|
||
# Update should never be updated here because user already exists, | ||
# but we have to specify it because otherwise ansible user reset password to empty string | ||
- name: Get user information for non-root | ||
ansible.builtin.user: | ||
name: '{{ managing_user }}' | ||
update_password: on_create | ||
state: present | ||
register: user_infos | ||
when: managing_user != 'root' | ||
|
||
- name: Be sure diagnostic packages are installed | ||
ansible.builtin.apt: | ||
name: '{{ diagnostic_packages }}' | ||
state: present | ||
|
||
- name: Include setup atop tasks | ||
ansible.builtin.import_tasks: setup_atop.yml | ||
tags: | ||
- atop | ||
|
||
- name: Include setup bottom tasks | ||
ansible.builtin.import_tasks: setup_bottom.yml | ||
tags: | ||
- bottom | ||
|
||
- name: Include setup btop tasks | ||
ansible.builtin.import_tasks: setup_btop.yml | ||
tags: | ||
- btop | ||
|
||
- name: Include setup glances tasks | ||
ansible.builtin.import_tasks: setup_glances.yml | ||
tags: | ||
- glances | ||
|
||
- name: Include setup htop tasks | ||
ansible.builtin.import_tasks: setup_htop.yml | ||
tags: | ||
- htop | ||
|
||
- name: Include setup sysstat tasks | ||
ansible.builtin.import_tasks: setup_sysstat.yml | ||
tags: | ||
- sysstat |
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,26 @@ | ||
--- | ||
|
||
# see https://www.atoptool.nl/ | ||
# see https://github.com/Atoptool/atop | ||
|
||
- name: Activated atop | ||
when: diagnostic_with_atop | ||
block: | ||
- name: Be sure atop package are installed | ||
ansible.builtin.apt: | ||
name: atop | ||
state: present | ||
|
||
- name: Disabled atop | ||
when: not diagnostic_with_atop | ||
block: | ||
- name: Remove atop packages | ||
ansible.builtin.apt: | ||
name: atop | ||
purge: true | ||
state: absent | ||
|
||
- name: Remove atop user configuration | ||
ansible.builtin.file: | ||
path: "{{ '/root' if managing_user == 'root' else user_infos.home }}/.atoprc" | ||
state: absent |
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 @@ | ||
--- | ||
|
||
# see https://github.com/ClementTsang/bottom | ||
|
||
- name: Activated bottom | ||
when: diagnostic_with_bottom | ||
block: | ||
- name: Be sure bottom package are installed | ||
ansible.builtin.apt: | ||
name: bottom | ||
state: present | ||
|
||
- name: Disabled bottom | ||
when: not diagnostic_with_bottom | ||
block: | ||
- name: Remove bottom packages | ||
ansible.builtin.apt: | ||
name: bottom | ||
purge: true | ||
state: absent |
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,25 @@ | ||
--- | ||
|
||
# see https://github.com/aristocratos/btop | ||
|
||
- name: Activated btop | ||
when: diagnostic_with_btop | ||
block: | ||
- name: Be sure btop package are installed | ||
ansible.builtin.apt: | ||
name: btop | ||
state: present | ||
|
||
- name: Disabled btop | ||
when: not diagnostic_with_btop | ||
block: | ||
- name: Remove btop packages | ||
ansible.builtin.apt: | ||
name: btop | ||
purge: true | ||
state: absent | ||
|
||
- name: Remove btop user configuration | ||
ansible.builtin.file: | ||
path: "{{ '/root' if managing_user == 'root' else user_infos.home }}/.config/btop" | ||
state: absent |
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,48 @@ | ||
--- | ||
|
||
# see https://github.com/nicolargo/glances | ||
|
||
- name: Activated glances | ||
when: diagnostic_with_glances | ||
block: | ||
- name: Use pip | ||
when: glances_with_pip | ||
block: | ||
- name: Include python role | ||
ansible.builtin.include_role: | ||
name: alphanodes.setup.python | ||
vars: | ||
python_pip_packages: '{{ glances_pip_packages }}' | ||
python_pip_default_venv: '{{ glances_pip_venv }}' | ||
|
||
- name: Use debian package | ||
when: not glances_with_pip | ||
block: | ||
- name: Be sure glances not installed with debian packages | ||
ansible.builtin.apt: | ||
name: glances | ||
state: absent | ||
|
||
- name: Remove obsolete glances without venv | ||
ansible.builtin.file: | ||
path: /usr/local/bin/glances | ||
state: absent | ||
|
||
- name: Disabled glances | ||
when: not diagnostic_with_glances | ||
block: | ||
- name: Remove glances venv | ||
ansible.builtin.file: | ||
path: '{{ python_venv_parent }}/{{ glances_pip_venv }}' | ||
state: absent | ||
|
||
- name: Remove glance package | ||
ansible.builtin.apt: | ||
name: glances | ||
purge: true | ||
state: absent | ||
|
||
- name: Remove glances user configuration | ||
ansible.builtin.file: | ||
path: "{{ '/root' if managing_user == 'root' else user_infos.home }}/.local/share/glances" | ||
state: absent |
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,34 @@ | ||
--- | ||
|
||
# see https://github.com/htop-dev/htop | ||
|
||
- name: Activated htop | ||
when: diagnostic_with_htop | ||
block: | ||
- name: Be sure htop package are installed | ||
ansible.builtin.apt: | ||
name: htop | ||
state: present | ||
|
||
# @see https://haydenjames.io/htop-heres-how-to-customize-it/ | ||
- name: Install htop configration | ||
ansible.builtin.copy: | ||
src: htoprc | ||
dest: "{{ '/root' if managing_user == 'root' else user_infos.home }}/.config/htop/" | ||
mode: 0644 | ||
owner: '{{ managing_user }}' | ||
group: "{{ 'root' if managing_user == 'root' else user_infos.group }}" | ||
|
||
- name: Disabled htop | ||
when: not diagnostic_with_htop | ||
block: | ||
- name: Remove htop packages | ||
ansible.builtin.apt: | ||
name: htop | ||
purge: true | ||
state: absent | ||
|
||
- name: Remove htop user configuration | ||
ansible.builtin.file: | ||
path: "{{ '/root' if managing_user == 'root' else user_infos.home }}/.config/htop" | ||
state: absent |
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 @@ | ||
--- | ||
|
||
# see https://nmap.org/ | ||
|
||
- name: Activated nmap | ||
when: diagnostic_with_nmap | ||
block: | ||
- name: Be sure nmap package are installed | ||
ansible.builtin.apt: | ||
name: nmap | ||
state: present | ||
|
||
- name: Disabled nmap | ||
when: not diagnostic_with_nmap | ||
block: | ||
- name: Remove nmap packages | ||
ansible.builtin.apt: | ||
name: nmap | ||
purge: true | ||
state: absent |
Oops, something went wrong.