From db8f50056b6e38f5cbf30919b1dabb565dc8fe38 Mon Sep 17 00:00:00 2001 From: Manu Bretelle Date: Mon, 18 Sep 2023 15:27:25 -0700 Subject: [PATCH] ansible: Install atop on Debian based hosts and default to 10s intervals atop is useful to be able to debug what happened historically. --- ansible/roles/base/defaults/main.yml | 3 ++ ansible/roles/base/tasks/setup-Debian.yml | 42 +++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/ansible/roles/base/defaults/main.yml b/ansible/roles/base/defaults/main.yml index bc201cd..cbcff0c 100644 --- a/ansible/roles/base/defaults/main.yml +++ b/ansible/roles/base/defaults/main.yml @@ -1,7 +1,10 @@ --- __base_packages: + - atop - curl - git - jq - python3-pip - vim + +atop_interval: 10 diff --git a/ansible/roles/base/tasks/setup-Debian.yml b/ansible/roles/base/tasks/setup-Debian.yml index 9c89783..a2f3ab9 100644 --- a/ansible/roles/base/tasks/setup-Debian.yml +++ b/ansible/roles/base/tasks/setup-Debian.yml @@ -16,3 +16,45 @@ state: stopped enabled: no masked: yes + +# When atopacct is running, it holds semaphore that prevent atop from working +# Further troubleshooting would need to be done, but atop can do just fine on its own. +# Note that even stopping `atopacct` leaves semaphores... either reboot or clean them +# manually. +# Possibly related: https://lkml.org/lkml/2016/12/19/182 +- name: Disable atopacct + become: true + ansible.builtin.service: + name: atopacct + state: stopped + enabled: false + +- name: Setup atop + become: true + ansible.builtin.copy: + dest: "/etc/default/atop" + content: | + # This file is generated by Ansible, do not modify + LOGOPTS="-R" + LOGINTERVAL={{ atop_interval }} + LOGGENERATIONS=28 + LOGPATH=/var/log/atop + mode: 0644 + owner: root + group: root + register: atop_conf + + +- name: Start and Enable atop + become: yes + ansible.builtin.service: + name: atop + state: started + enabled: yes + +- name: restart atop + become: yes + service: + name: atop + state: restarted + when: atop_conf.changed