首页 > 解决方案 > ansible 中的 apt 模块产生“无法锁定 apt 以进行独占操作”

问题描述

我有一本剧本,它一次为本地主机运行相同的角色,一次为两个远程主机运行。

- hosts: remote   
  connection: local
  become: yes 
  roles: 
      - installBasicDeb   

除了单个任务外,该角色为空:

- name: check that basics packages are present
  apt:
    name:
          - apt-transport-https
          - software-properties-common 
          - members
          - filezilla
          - net-tools
    state: present
    update_cache: true
  become: true
  register: apt_output

- debug: var=apt_output

该剧本与sudo ansible-playbook -b -i ./hosts install2_playbook.yml (我也尝试过--ask-become-pass)一起运行,任务成功两次,一次失败,并出现“无法锁定 apt 以进行独占操作”。

我可以ssh在两台远程主机上,使用sudo(使用相同的密码)并执行apt update命令。我没有看到另一个 apt 作业正在运行(计算机是一个几个小时..)。

失败的主机是(ARM aarch64)ubuntu 20.10,suceedng 主机是 Debian 10 安装。这是否解释了差异?

我必须改变什么才能使所有主机都成功?我是anisble的新用户...谢谢您的帮助!

标签: ansible

解决方案


推荐阅读