TASK [install-kubernetes : Disable swap] fatal: [127.0.0.1]: FAILED! => {"changed": true, "cmd": ["/sbin/swapoff", "-a"]

Dear’s

How to disable/remove/ignored only one task in ansible playbook?

Status:

diyander@Ander:~/bin/ansible/playbooks$ ansible-playbook -K clara.yml
BECOME password: 

PLAY [localhost] *********************************************************************************************************************************

TASK [Gathering Facts] ***************************************************************************************************************************
ok: [127.0.0.1]

TASK [Install Nvidia Docker] *********************************************************************************************************************

TASK [install-nvidia-docker : Install Docker CE] *************************************************************************************************
included: /home/diyander/bin/ansible/playbooks/roles/install-nvidia-docker/tasks/install-docker-ce.yml for 127.0.0.1

TASK [install-nvidia-docker : Add package ca-certificates before adding GPG keys] ****************************************************************
ok: [127.0.0.1]

TASK [install-nvidia-docker : Add apt package apt-transport-https before adding GPG keys] ********************************************************
ok: [127.0.0.1]

TASK [install-nvidia-docker : Add Docker CE GPG Apt Key (Ubuntu)] ********************************************************************************
skipping: [127.0.0.1]

TASK [install-nvidia-docker : Add Docker CE Repository (Bionic)] *********************************************************************************
skipping: [127.0.0.1]

TASK [install-nvidia-docker : Update apt and Install Docker CE on Bionic] ************************************************************************
skipping: [127.0.0.1]

TASK [install-nvidia-docker : Update apt and Install Docker.io on Focal] *************************************************************************
ok: [127.0.0.1]

TASK [install-nvidia-docker : Add the user to Docker group] **************************************************************************************
ok: [127.0.0.1]

TASK [install-nvidia-docker : Install Nvidia Docker 2] *******************************************************************************************
included: /home/diyander/bin/ansible/playbooks/roles/install-nvidia-docker/tasks/install-nvidia-docker.yml for 127.0.0.1

TASK [install-nvidia-docker : Add Repository Key] ************************************************************************************************
ok: [127.0.0.1]

TASK [install-nvidia-docker : Add Repository Source] *********************************************************************************************
ok: [127.0.0.1]

TASK [install-nvidia-docker : Install Nvidia Docker 2] *******************************************************************************************
ok: [127.0.0.1]

TASK [install-nvidia-docker : Update daemon.json with NVIDIA as Default Runtime] *****************************************************************
ok: [127.0.0.1]

TASK [install-nvidia-docker : Reload Docker Configuration] ***************************************************************************************
skipping: [127.0.0.1]

TASK [Install Kubernetes Configured for Clara] ***************************************************************************************************

TASK [install-kubernetes : Turn Swap Off] ********************************************************************************************************
included: /home/diyander/bin/ansible/playbooks/roles/install-kubernetes/tasks/swapoff.yml for 127.0.0.1

TASK [install-kubernetes : Remove swapfile from /etc/fstab] **************************************************************************************
ok: [127.0.0.1] => (item=swap)
ok: [127.0.0.1] => (item=none)

TASK [install-kubernetes : check swap] ***********************************************************************************************************
ok: [127.0.0.1]

TASK [install-kubernetes : Disable swap] *********************************************************************************************************
fatal: [127.0.0.1]: FAILED! => {"changed": true, "cmd": ["/sbin/swapoff", "-a"], "delta": "0:00:00.003123", "end": "2021-10-14 00:25:40.729705", "msg": "non-zero return code", "rc": 255, "start": "2021-10-14 00:25:40.726582", "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}

PLAY RECAP ***************************************************************************************************************************************
127.0.0.1                  : ok=14   changed=0    unreachable=0    failed=1    skipped=4    rescued=0    ignored=0

My Configuration:

Attached GPUs : 1
GPU 00000000:01:00.0
Product Name : NVIDIA GeForce RTX 2070 SUPER
Product Brand : GeForce
Windows 11 pro version 21H2 build 22000.194
WSL2 - Distributor ID: Ubuntu - Description: Ubuntu 20.04.3 LTS - Release: 20.04
Docker Desktop version 4.1.0
ansible [core 2.11.6]

Best Regards!
@diyanderson

Hi @diyanderson
Thank you for trying out Clara Deploy SDK!

We didn’t test on Windows WSL2 and it seems that WSL2 doesn’t use swap by default and executing /sbin/swapoff -a always return an error code (255).

As a workaround, could you please editroles/install-kubernetes/tasks/swapoff.yml file and remove the following statements?

- name: Disable swap
  become: yes
  command: /sbin/swapoff -a
  when: swapon.stdout

Thank you!

Related Information
“swapoff -a” returns error code 255 on Ubuntu 16.04 and WSL 2. · Issue #4918 · microsoft/WSL (github.com)

1 Like

@gigony Thanks!! it helped a lot !!

See:

see the answer “ansible”

diyander@Ander:~/bin/ansible$ cd ~/bin/ansible/playbooks/
diyander@Ander:~/bin/ansible/playbooks$ sudo ansible-playbook -K clara.yml
BECOME password: 

PLAY [localhost] *********************************************************************************************************************************

TASK [Gathering Facts] ***************************************************************************************************************************
ok: [127.0.0.1]

TASK [Install Nvidia Docker] *********************************************************************************************************************

TASK [install-nvidia-docker : Install Docker CE] *************************************************************************************************
included: /home/diyander/bin/ansible/playbooks/roles/install-nvidia-docker/tasks/install-docker-ce.yml for 127.0.0.1

TASK [install-nvidia-docker : Add package ca-certificates before adding GPG keys] ****************************************************************
ok: [127.0.0.1]

TASK [install-nvidia-docker : Add apt package apt-transport-https before adding GPG keys] ********************************************************
ok: [127.0.0.1]

TASK [install-nvidia-docker : Add Docker CE GPG Apt Key (Ubuntu)] ********************************************************************************
skipping: [127.0.0.1]

TASK [install-nvidia-docker : Add Docker CE Repository (Bionic)] *********************************************************************************
skipping: [127.0.0.1]

TASK [install-nvidia-docker : Update apt and Install Docker CE on Bionic] ************************************************************************
skipping: [127.0.0.1]

TASK [install-nvidia-docker : Update apt and Install Docker.io on Focal] *************************************************************************
ok: [127.0.0.1]

TASK [install-nvidia-docker : Add the user to Docker group] **************************************************************************************
ok: [127.0.0.1]

TASK [install-nvidia-docker : Install Nvidia Docker 2] *******************************************************************************************
included: /home/diyander/bin/ansible/playbooks/roles/install-nvidia-docker/tasks/install-nvidia-docker.yml for 127.0.0.1

TASK [install-nvidia-docker : Add Repository Key] ************************************************************************************************
ok: [127.0.0.1]

TASK [install-nvidia-docker : Add Repository Source] *********************************************************************************************
ok: [127.0.0.1]

TASK [install-nvidia-docker : Install Nvidia Docker 2] *******************************************************************************************
ok: [127.0.0.1]

TASK [install-nvidia-docker : Update daemon.json with NVIDIA as Default Runtime] *****************************************************************
ok: [127.0.0.1]

TASK [install-nvidia-docker : Reload Docker Configuration] ***************************************************************************************
skipping: [127.0.0.1]

TASK [Install Kubernetes Configured for Clara] ***************************************************************************************************

TASK [install-kubernetes : Turn Swap Off] ********************************************************************************************************
included: /home/diyander/bin/ansible/playbooks/roles/install-kubernetes/tasks/swapoff.yml for 127.0.0.1

TASK [install-kubernetes : Remove swapfile from /etc/fstab] **************************************************************************************
ok: [127.0.0.1] => (item=swap)
ok: [127.0.0.1] => (item=none)

TASK [install-kubernetes : check swap] ***********************************************************************************************************
ok: [127.0.0.1]

TASK [install-kubernetes : Install Kubernetes] ***************************************************************************************************
included: /home/diyander/bin/ansible/playbooks/roles/install-kubernetes/tasks/install-kubernetes.yml for 127.0.0.1

TASK [install-kubernetes : Add K8s GPG apt Key] **************************************************************************************************
changed: [127.0.0.1]

TASK [install-kubernetes : Add Kubernetes Repository] ********************************************************************************************
changed: [127.0.0.1]

TASK [install-kubernetes : Update apt and Install kubelet] ***************************************************************************************
changed: [127.0.0.1]

TASK [install-kubernetes : Hold kubelet at current version] **************************************************************************************
changed: [127.0.0.1]

TASK [install-kubernetes : Update apt and Install kubeadm] ***************************************************************************************
changed: [127.0.0.1]

TASK [install-kubernetes : Hold kubeadm at current version] **************************************************************************************
changed: [127.0.0.1]

TASK [install-kubernetes : Update apt and Install kubectl] ***************************************************************************************
changed: [127.0.0.1]

TASK [install-kubernetes : Hold kubectl at current version] **************************************************************************************
changed: [127.0.0.1]

TASK [install-kubernetes : Copy Kubernetes Files to Remote Host] *********************************************************************************
changed: [127.0.0.1] => (item=kube-flannel-rbac.yml)

TASK [install-kubernetes : Add kube-flannel template] ********************************************************************************************
changed: [127.0.0.1]

TASK [install-kubernetes : Check if Kubernetes is initialized] ***********************************************************************************
ok: [127.0.0.1]

TASK [install-kubernetes : Check if Kubernetes has been initiated] *******************************************************************************
skipping: [127.0.0.1]

TASK [install-kubernetes : Initialize kubeadm] ***************************************************************************************************
fatal: [127.0.0.1]: FAILED! => {"changed": true, "cmd": "kubeadm init --pod-network-cidr=\"10.254.0.0/16\" --apiserver-cert-extra-sans=\"172.26.254.60\" --log-file=/tmp/kubernetes_init.log", "delta": "0:00:01.690996", "end": "2021-10-14 17:18:15.505140", "msg": "non-zero return code", "rc": 1, "start": "2021-10-14 17:18:13.814144", "stderr": "I1014 17:18:14.721488    7141 version.go:252] remote version is much newer: v1.22.2; falling back to: stable-1.19\nW1014 17:18:15.201733    7141 configset.go:348] WARNING: kubeadm cannot validate component configs for API groups [kubelet.config.k8s.io kubeproxy.config.k8s.io]\n\t[WARNING IsDockerSystemdCheck]: detected \"cgroupfs\" as the Docker cgroup driver. The recommended driver is \"systemd\". Please follow the guide at https://kubernetes.io/docs/setup/cri/\n\t[WARNING SystemVerification]: this Docker version is not on the list of validated versions: 20.10.8. Latest validated version: 19.03\nerror execution phase preflight: [preflight] Some fatal errors occurred:\n\t[ERROR Service-Docker]: docker service is not active, please run 'systemctl start docker.service'\n\t[ERROR Swap]: running with swap on is not supported. Please disable swap\n[preflight] If you know what you are doing, you can make a check non-fatal with `--ignore-preflight-errors=...`\nTo see the stack trace of this error execute with --v=5 or higher", "stderr_lines": ["I1014 17:18:14.721488    7141 version.go:252] remote version is much newer: v1.22.2; falling back to: stable-1.19", "W1014 17:18:15.201733    7141 configset.go:348] WARNING: kubeadm cannot validate component configs for API groups [kubelet.config.k8s.io kubeproxy.config.k8s.io]", "\t[WARNING IsDockerSystemdCheck]: detected \"cgroupfs\" as the Docker cgroup driver. The recommended driver is \"systemd\". Please follow the guide at https://kubernetes.io/docs/setup/cri/", "\t[WARNING SystemVerification]: this Docker version is not on the list of validated versions: 20.10.8. Latest validated version: 19.03", "error execution phase preflight: [preflight] Some fatal errors occurred:", "\t[ERROR Service-Docker]: docker service is not active, please run 'systemctl start docker.service'", "\t[ERROR Swap]: running with swap on is not supported. Please disable swap", "[preflight] If you know what you are doing, you can make a check non-fatal with `--ignore-preflight-errors=...`", "To see the stack trace of this error execute with --v=5 or higher"], "stdout": "[init] Using Kubernetes version: v1.19.15\n[preflight] Running pre-flight checks", "stdout_lines": ["[init] Using Kubernetes version: v1.19.15", "[preflight] Running pre-flight checks"]}

PLAY RECAP ***************************************************************************************************************************************
127.0.0.1                  : ok=26   changed=10   unreachable=0    failed=1    skipped=5    rescued=0    ignored=0   

some errors, subject to another topic…
Thanks, Best Regards!!
@diyanderson