
Ubuntu 18.04.1 VPS를 설정하기 위해 Ansible 플레이북을 생성 중인데 Python을 안정적으로 설치할 수 없는 문제가 발생했습니다.
apt -y update && apt -y install python
Ubuntu 18.04.1은 Python이 설치된 상태로 제공되지 않으므로 모듈 과 함께 다음 명령을 사용해야 합니다 raw
.
또한 수동으로 ssh로 연결한 셸에서도 이 오류가 발생했습니다.
root@ansible:~# apt -y update && apt -y install python
Hit:1 http://archive.ubuntu.com/ubuntu bionic InRelease
Hit:2 http://archive.ubuntu.com/ubuntu bionic-security InRelease
Hit:3 http://archive.ubuntu.com/ubuntu bionic-updates InRelease
Reading package lists... Done
Building dependency tree
Reading state information... Done
17 packages can be upgraded. Run 'apt list --upgradable' to see them.
E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)
E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?
이것은 Windows 호스트의 VirtualBox에 있는 가상 머신입니다.
sync
나는 또한 between apt update
and 를 사용해 보았고 심지어 and 사이에 apt install
이와 같은 작업을 시도했지만 일반적으로 실패합니다.while fuser /var/lib/dpkg/lock >/dev/null 2>&1; do sync && sleep 1; done
update
install
이는 다음 단계를 통해 구성된 시스템입니다.https://askubuntu.com/questions/946787/ubuntu-server-installation-with-root-only/1066033#1066033
답변1
Ubuntu 16.04+, iirc는 기본적으로 Python3과 함께 제공되며 기본 설치에서 Python2를 완전히 제거했습니다. 즉, 작동하는 Python 인터프리터가 있지만 Ansible이 보이는 곳에는 없습니다.
Ubuntu 16.04+의 경우 변수를 사용하고 로 설정하여 기본 동작( python
명령으로 예상) 을 재정의할 수 있습니다 .ansible_python_interpreter
/usr/bin/python3
그래서 다음과 같습니다.
ansible_python_interpreter: /usr/bin/python3
Ansible은 이제 Python3을 대부분의 경우 일류 시민으로 취급하므로 이는 매우 안전한 변경입니다. 나는 문제없이 관리하는 소수의 Ubuntu 18.04 상자에서 그것을 사용하고 있습니다.