I’m encountering an issue while running an Ansible playbook to set up a Kubernetes cluster. The playbook includes tasks to install Kubernetes components (kubelet , kubeadm , kubectl ) on multiple nodes. However, I’m facing the following error:
FAILED! => {"cache_update_time": 1716572708, "cache_updated": false, "changed": false, "msg": "'/usr/bin/apt-get -y -o "Dpkg::Options::=--force-confdef" -o "Dpkg::Options::=--force-confold" install 'kubelet=1.29.5-1.1''kubeadm=1.29.5-1.1''kubectl=1.29.5-1.1'' failed: E: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 7277 (apt-get)\nE: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?\n", "rc": 100, "stderr": "E: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 7277 (apt-get)\nE: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?\n", "stderr_lines": ["E: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 7277 (apt-get)", "E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?"], "stdout": "", "stdout_lines": []}
This error suggests that another process is currently holding the lock on /var/lib/dpkg/lock-frontend, preventing the installation process from proceeding. I suspect this might be due to another apt-get process running concurrently.
Here’s a effected part of the playbook:
- name: add Kubernetes apt-key get_url: url: https://pkgs.k8s.io/core:/stable:/v1.29/deb/Release.key dest: /etc/apt/keyrings/kubernetes-apt-keyring.asc mode: '0644' force: true - name: add Kubernetes' APT repository ansible.builtin.apt_repository: repo: "deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.asc] https://pkgs.k8s.io/core:/stable:/v1.29/deb/ /" state: present update_cache: yes - name: Install kubeadm, kubectl, kubelet ansible.builtin.apt: pkg: - kubelet - kubeadm - kubectl state: present
Any insights or suggestions on how to resolve this problem in Ansible would be greatly appreciated. Thank you!