Don’t Save Too Much
Managing file systems to ensure they do not become constantly full is crucial in regular server operations. However, did you know that this is not only a best practice for server operations but also a best practice in the context of IT GreenOps? This is because the more data a server stores, the more power it consumes, increasing CO2 emissions. Even if the server uses renewable energy, the need for new devices to accommodate the increase in stored data would increase Embodied-Carbon emissions.
In this article, I introduce how to manage filesystems using Performance Co-Pilot(PCP) and Ansible to manage the systems automatically. Ultimately, this approach will lead to stable server operations and reduced IT operation costs.
Setting up Performance Co-Pilot(PCP) on the managed Linux servers.
Performance Co-Pilot is a service for performance rule evaluation. You can find more information here: https://pcp.io/documentation.html
In this article, we’ll setup PCP on the managed linux servers.
Here is a workflow:
Let’s setup PCP on your Linux servers!
Note: You need to copy ssh keys to the managed servers before perform the below steps. Or if you would like to use ssh password to login to the managed nodes, follow here to build an Ansible inventory file.
First, create inventory.yaml file with the below code. Modify IP addresses and sudo password
. You can replace 192.168.57.10/192.168.57.11
with your server’s IP and replace ansible_become_pass: changeme
with your sudo password
.
---
all:
children:
pcp_servers:
hosts:
192.168.57.10:
ansible_become_pass: changeme
192.168.57.11:
ansible_become_pass: changeme
Next, create a playbook with the below code.
---
- hosts: pcp_servers
become: true
gather_facts: no
tasks:
- ansible.builtin.include_vars: playbooks/vars/webhook.yml
- name: Install pcp packages on the managed nodes
ansible.builtin.dnf:
name: "{{ item }}"
state: latest
loop:
- pcp
- name: Install additional packages for stress test and analyze performance
ansible.builtin.dnf:
name: "{{ item }}"
state: latest
loop:
- sysstat
- stress-ng
- name: Start and enable pmcd service
ansible.builtin.systemd_service:
name: pmcd
state: started
enabled: true
- name: Start and enable pmcd service
ansible.builtin.systemd_service:
name: pmie
state: started
enabled: true
- name: Start and enable pmcd service
ansible.builtin.systemd_service:
name: pmlogger
state: started
enabled: true
- name: Configure global webhook_action as "yes"
command: "pmieconf -f /var/lib/pcp/config/pmie/config.default modify global webhook_action yes"
- name: Configure webhook endpoint
command: "pmieconf -f /var/lib/pcp/config/pmie/config.default modify global webhook_endpoint {{ webhook_endpoint }}"
loop: "{{ groups['pcp_servers'] }}"
notify: Restart pmie
handlers:
- name: Restart pmie
ansible.builtin.systemd_service:
name: pmie
state: restarted
enabled: true
After that, run this playbook with the following command:
$ ansible-playbook pre_setup.yml
Summary
This is the end of the pre-setup of this project, completed to run the PCP service. We’ll explore deeper to manage filesystems in an efficient way!
Pingback: Filesystem Management in a greenway using Ansible and Event-Driven Automation(2) - GreenOps Lab