Or you can set the vm.swappiness sysctl to 0.
- name: install foo
apt:
pkg: foo
state: present
could be available as: from pyinfra import ansible
ansible(name='install foo').apt(pkg='foo', state='present')
where the `ansible` function itself would know nothing about apt, just forward everything to the Ansible module.