Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apt upgrade on amazon ubuntu #22

Closed
qiaofeng1227 opened this issue Jul 6, 2021 · 7 comments
Closed

apt upgrade on amazon ubuntu #22

qiaofeng1227 opened this issue Jul 6, 2021 · 7 comments
Assignees

Comments

@qiaofeng1227
Copy link
Contributor

TASK [role_common : Upgrade all packages to the latest version] *************************************************************************************************************************************************************************
fatal: [100.25.148.13]: FAILED! => {"changed": false, "msg": "'/usr/bin/apt-get upgrade --with-new-pkgs --auto-remove' failed: E: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 9823 (apt)\nE: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?\n", "rc": 100, "stdout": "", "stdout_lines": []}
@qiaofeng1227 qiaofeng1227 self-assigned this Jul 6, 2021
@qiaofeng1227
Copy link
Contributor Author

create a new vm on amazon ubuntu
image

@qiaofeng1227
Copy link
Contributor Author

qiaofeng1227 commented Jul 6, 2021

when apt install package, lock file update

root@ip-172-31-45-249:/data# apt install ansible
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  ieee-data python3-argcomplete python3-crypto python3-dnspython python3-jmespath python3-kerberos python3-libcloud python3-lockfile python3-netaddr python3-ntlm-auth python3-requests-kerberos python3-requests-ntlm python3-selinux
  python3-winrm python3-xmltodict

image

@qiaofeng1227
Copy link
Contributor Author

image

@qiaofeng1227
Copy link
Contributor Author

@qiaofeng1227
Copy link
Contributor Author

the same issure refer to:(2019 to nowe , stilll opening)
ansible/ansible#51663
ansible/ansible#74095

@qiaofeng1227
Copy link
Contributor Author

@chendelin1982
Copy link
Contributor

chendelin1982 commented Jan 6, 2022

What reason make apt file locked?

install.sh file have many package to install, especially apt install ansible need more time 50s

final solution

- name: Upgrade all packages to the latest version for production
  apt:
    name: "*"
    state: latest
    only_upgrade: yes
  register: result
  until: result.msg.find("Could not get lock /var/lib/dpkg") == -1  
  retries: 50
  delay: 10
  failed_when: "'FAILED' in result.stdout"
  when: common_system_upgrade and (init == '1' or init == 1)

why this solution?

try it and wait for unlocked

  1. until = while
  2. retry 50 times and delay 10s every time, nearly 500s (6 mins)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants