From a79961605ab698c5f2ba9723e32a73b42c1c85a0 Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Fri, 1 Sep 2023 15:42:29 -0400 Subject: [PATCH] Replace per-user htoprc with system-wide config Also update to newer htoprc layout from BLSE. --- roles/base/tasks/main.yml | 39 +++++++-------- roles/base/templates/etc/htoprc.j2 | 48 +++++++++++++++++++ .../var/home/user/config/htop/htoprc.j2 | 25 ---------- 3 files changed, 65 insertions(+), 47 deletions(-) create mode 100644 roles/base/templates/etc/htoprc.j2 delete mode 100644 roles/base/templates/var/home/user/config/htop/htoprc.j2 diff --git a/roles/base/tasks/main.yml b/roles/base/tasks/main.yml index 8a661d1..79333ee 100644 --- a/roles/base/tasks/main.yml +++ b/roles/base/tasks/main.yml @@ -596,6 +596,14 @@ state: absent tags: base-shell +# htop +- name: install htop configuration + template: + src: "etc/htoprc.j2" + dest: "/etc/htoprc" + mode: 0644 + tags: base-shell + # fail2ban - name: install fail2ban configurations template: @@ -741,11 +749,13 @@ - users - user-root -- name: write htoprc to homedir - template: - src: var/home/user/config/htop/htoprc.j2 - dest: /root/.htoprc - mode: 0600 +- name: remove root htoprc + file: + dest: "{{ item }}" + state: absent + loop: + - /root/.htoprc + - /root/.config/htop tags: - users - user-root @@ -960,25 +970,10 @@ - users - user-admin -- name: ensure htop config directory exists +- name: remove user htop configuration directory file: dest: "/var/home/{{ item.name }}/.config/htop" - state: directory - owner: "{{ item.name }}" - group: operator - mode: 0755 - with_items: "{{ admin_users }}" - tags: - - users - - user-admin - -- name: write htoprc to homedir - template: - src: var/home/user/config/htop/htoprc.j2 - dest: "/var/home/{{ item.name }}/.config/htop/htoprc" - owner: "{{ item.name }}" - group: operator - mode: 0644 + state: absent with_items: "{{ admin_users }}" tags: - users diff --git a/roles/base/templates/etc/htoprc.j2 b/roles/base/templates/etc/htoprc.j2 new file mode 100644 index 0000000..5343b2a --- /dev/null +++ b/roles/base/templates/etc/htoprc.j2 @@ -0,0 +1,48 @@ +# htop configuration file (Debian) +# {{ ansible_managed }} +fields=0 48 17 18 38 39 40 2 46 47 49 1 +sort_key=46 +{% if debian_version|int >= 11 %} +sort_direction=0 +{% else %} +sort_direction=1 +{% endif %} +tree_sort_key=0 +tree_sort_direction=1 +hide_kernel_threads=0 +hide_userland_threads=0 +shadow_other_users=0 +show_thread_names=1 +show_program_path=1 +highlight_base_name=1 +highlight_megabytes=1 +highlight_threads=1 +highlight_changes=0 +highlight_changes_delay_secs=5 +find_comm_in_cmdline=1 +strip_exe_from_cmdline=1 +show_merged_command=0 +tree_view=0 +tree_view_always_by_pid=0 +header_margin=1 +detailed_cpu_time=1 +cpu_count_from_one=1 +show_cpu_usage=1 +show_cpu_frequency=1 +show_cpu_temperature=1 +degree_fahrenheit=0 +update_process_names=1 +account_guest_in_cpu_meter=1 +color_scheme=0 +enable_mouse=1 +delay=10 +left_meters=Hostname Clock Uptime Blank LeftCPUs2 Blank CPU Blank +left_meter_modes=2 2 2 2 1 2 1 2 +{% if debian_version|int >= 11 %} +right_meters=LoadAverage Tasks Systemd Blank RightCPUs2 Blank Memory Swap +right_meter_modes=2 2 2 2 1 2 1 1 +{% else %} +right_meters=LoadAverage Tasks Blank Blank RightCPUs2 Blank Memory Swap +right_meter_modes=2 2 2 2 1 2 1 1 +{% endif %} +hide_function_bar=0 diff --git a/roles/base/templates/var/home/user/config/htop/htoprc.j2 b/roles/base/templates/var/home/user/config/htop/htoprc.j2 deleted file mode 100644 index f0311f0..0000000 --- a/roles/base/templates/var/home/user/config/htop/htoprc.j2 +++ /dev/null @@ -1,25 +0,0 @@ -# htop config file -# {{ ansible_managed }} -fields=0 48 17 18 38 39 40 2 46 47 49 1 -sort_key=46 -sort_direction=1 -hide_threads=0 -hide_kernel_threads=0 -hide_userland_threads=0 -shadow_other_users=0 -show_thread_names=1 -highlight_base_name=1 -highlight_megabytes=1 -highlight_threads=1 -tree_view=0 -header_margin=1 -detailed_cpu_time=1 -cpu_count_from_zero=0 -update_process_names=1 -account_guest_in_cpu_meter=1 -color_scheme=0 -delay=15 -left_meters=LeftCPUs2 Blank CPU Blank Blank Memory Swap -left_meter_modes=1 2 1 2 2 1 1 -right_meters=RightCPUs2 Blank LoadAverage Tasks Blank Hostname Clock Uptime Blank -right_meter_modes=1 2 2 2 2 2 2 2 2