From 2c7c956be9f417f6b747d5ccb587e7c8fe9a053e Mon Sep 17 00:00:00 2001 From: mkrasilnikov Date: Fri, 27 Oct 2017 19:57:12 +0300 Subject: [PATCH] Disable swap in vagrant vms --- Vagrantfile | 3 +++ roles/kubernetes/preinstall/tasks/verify-settings.yml | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/Vagrantfile b/Vagrantfile index 49325a601..40109f9b3 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -129,6 +129,9 @@ Vagrant.configure("2") do |config| config.vm.provision "shell", inline: "service network restart", run: "always" end + # Disable swap for each vm + config.vm.provision "shell", inline: "swapoff -a" + # Only execute once the Ansible provisioner, # when all the machines are up and ready. if i == $num_instances diff --git a/roles/kubernetes/preinstall/tasks/verify-settings.yml b/roles/kubernetes/preinstall/tasks/verify-settings.yml index 288964bd1..cbb5357b3 100644 --- a/roles/kubernetes/preinstall/tasks/verify-settings.yml +++ b/roles/kubernetes/preinstall/tasks/verify-settings.yml @@ -71,3 +71,9 @@ command: ping -c1 {{ access_ip }} when: access_ip is defined ignore_errors: "{{ ignore_assert_errors }}" + +- name: Stop if swap enabled + assert: + that: ansible_swaptotal_mb == 0 + when: kubelet_fail_swap_on|default(true) + ignore_errors: "{{ ignore_assert_errors }}"