Skip to content

Instantly share code, notes, and snippets.

@noonedeadpunk
Last active May 28, 2021 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save noonedeadpunk/a4e691e64da031084c071b554a5b40cd to your computer and use it in GitHub Desktop.
Save noonedeadpunk/a4e691e64da031084c071b554a5b40cd to your computer and use it in GitHub Desktop.
---
- hosts: compute_hosts
gather_facts: true
vars:
# We leave 1 full CPU as a spare one for hypervisor
cpu_spare: "{{ ansible_processor_threads_per_core }}"
cpu_quota: "{{ ansible_processor_vcpus * 100 - cpu_spare * 100 }}%"
tasks:
- name: Update machine.slice
blockinfile:
path: /etc/systemd/system/machine.slice.d/override.conf
create: yes
block: |
[Slice]
CPUQuota={{ cpu_quota }}
- name: Reaload machine.slice
systemd:
daemon_reload: yes
- name: Applying quota for runtime
command: systemctl set-property --runtime machine.slice "CPUQuota={{ cpu_quota }}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment