summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Ilvokhin <d@ilvokhin.com>2023-12-21 12:16:12 +0000
committerDmitry Ilvokhin <d@ilvokhin.com>2023-12-21 12:16:12 +0000
commita6f60f26c154aa4227921efa134cffdb5b9804de (patch)
tree7a42d022b699ec7e3d847b862b58548a58bb9092
parent616753b16cd7a3d00716047d3e58581c6e37805a (diff)
downloadinfra-a6f60f26c154aa4227921efa134cffdb5b9804de.tar.gz
infra-a6f60f26c154aa4227921efa134cffdb5b9804de.tar.bz2
infra-a6f60f26c154aa4227921efa134cffdb5b9804de.zip
Add atop setup task
-rw-r--r--roles/essential/handlers/atop.yml4
-rw-r--r--roles/essential/handlers/main.yml1
-rw-r--r--roles/essential/tasks/atop.yml38
-rw-r--r--roles/essential/tasks/main.yml7
4 files changed, 47 insertions, 3 deletions
diff --git a/roles/essential/handlers/atop.yml b/roles/essential/handlers/atop.yml
new file mode 100644
index 0000000..33ed20d
--- /dev/null
+++ b/roles/essential/handlers/atop.yml
@@ -0,0 +1,4 @@
+- name: Restart atop
+ ansible.builtin.service:
+ name: atop
+ state: restarted
diff --git a/roles/essential/handlers/main.yml b/roles/essential/handlers/main.yml
new file mode 100644
index 0000000..2ea72d6
--- /dev/null
+++ b/roles/essential/handlers/main.yml
@@ -0,0 +1 @@
+- ansible.builtin.import_tasks: roles/essential/handlers/atop.yml
diff --git a/roles/essential/tasks/atop.yml b/roles/essential/tasks/atop.yml
new file mode 100644
index 0000000..ccc699c
--- /dev/null
+++ b/roles/essential/tasks/atop.yml
@@ -0,0 +1,38 @@
+- name: Install atop
+ ansible.builtin.package:
+ name:
+ - atop
+ state: present
+
+- name: Setup per-minute atop snapshot
+ ansible.builtin.lineinfile:
+ dest: /etc/default/atop
+ state: present
+ regexp: '^#?LOGINTERVAL='
+ line: 'LOGINTERVAL=60'
+ owner: root
+ group: root
+ mode: u+rw,g+r,o+r
+ notify:
+ - Restart atop
+
+- name: Setup logrotate to save 7 days of logs for atop
+ ansible.builtin.lineinfile:
+ dest: /etc/default/atop
+ state: present
+ regexp: '^#?LOGGENERATIONS='
+ line: 'LOGGENERATIONS=7'
+ owner: root
+ group: root
+ mode: u+rw,g+r,o+r
+ notify:
+ - Restart atop
+
+- name: Enable atop systemd unit and logrotate timer
+ ansible.builtin.service:
+ name: '{{ item }}'
+ enabled: yes
+ state: started
+ loop:
+ - atop
+ - atop-rotate.timer
diff --git a/roles/essential/tasks/main.yml b/roles/essential/tasks/main.yml
index 87be2e5..fbcf875 100644
--- a/roles/essential/tasks/main.yml
+++ b/roles/essential/tasks/main.yml
@@ -1,3 +1,4 @@
-- ansible.builtin.include_tasks: roles/essential/tasks/packages.yml
-- ansible.builtin.include_tasks: roles/essential/tasks/users.yml
-- ansible.builtin.include_tasks: roles/essential/tasks/sudo.yml
+- ansible.builtin.import_tasks: roles/essential/tasks/packages.yml
+- ansible.builtin.import_tasks: roles/essential/tasks/users.yml
+- ansible.builtin.import_tasks: roles/essential/tasks/sudo.yml
+- ansible.builtin.import_tasks: roles/essential/tasks/atop.yml