Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
---
- 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