我使用ansible脚本在Amazon EC2和流浪盒中设置我的环境(Ubuntu)。然后我尝试在GermanVPS(Ubuntu Minimal)上设置相同的环境。使用Apt安装软件包似乎不起作用。
我跑
ansible-playbook -i ansible/live -u priidu ansible/caselaw.yml -s -vvvv --start-at-task="install"
会出现以下错误。
failed: [master] => (item=postgresql-9.4,postgresql-contrib-9.4,postgresql-server-dev-9.4,python-psycopg2) => {"failed": true, "item": "postgresql-9.4,postgresql-contrib-9.4,postgresql-server-dev-9.4,python-psycopg2"}
stderr: E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem.
msg: '/usr/bin/apt-get -y -o "Dpkg::Options::=--force-confdef" -o "Dpkg::Options::=--force-confold" install 'postgresql-server-dev-9.4' 'python-psycopg2'' failed: E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem.
FATAL: all hosts have already failed -- aborting
然后我尝试
ansible-playbook -i ansible/live -u priidu ansible/caselaw.yml -s -vvvv --start-at-task="dpkg configure"
我收到以下错误消息
failed: [master] => (item=postgresql-9.4,postgresql-contrib-9.4,postgresql-server-dev-9.4,python-psycopg2) => {"failed": true, "item": "postgresql-9.4,postgresql-contrib-9.4,postgresql-server-dev-9.4,python-psycopg2", "parsed": false}
BECOME-SUCCESS-grensagvuewehoylwpjytnkzpwwqgsre
Killed
OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
debug1: Reading configuration data /Users/priidukull/.ssh/config
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 51: Applying options for *
debug1: auto-mux: Trying existing master
debug2: fd 3 setting O_NONBLOCK
debug2: mux_client_hello_exchange: master version 4
debug3: mux_client_forwards: request forwardings: 0 local, 0 remote
debug3: mux_client_request_session: entering
debug3: mux_client_request_alive: entering
debug3: mux_client_request_alive: done pid = 54431
debug3: mux_client_request_session: session request sent
debug1: mux_client_request_session: master session id: 2
debug3: mux_client_read_packet: read header failed: Broken pipe
debug2: Received exit status from master 0
Shared connection to <<hostname>> closed.
FATAL: all hosts have already failed -- aborting
那里发生了什么,我该如何开始解决难题?
编辑:我的剧本的相关部分
- name: dpkg configure
shell: dpkg --configure -a
- name: install
apt: name={{ item }} update_cache=yes
with_items:
- postgresql-9.4
- postgresql-contrib-9.4
- postgresql-server-dev-9.4
- python-psycopg2
编辑2:添加了剧本命令。
编辑3:当我将RAM从64MB增加到512MB时,问题就消失了。
答案 0 :(得分:1)
当我尝试通过ansible-playbook安装docker时遇到了这个问题。
我尝试将RAM从512Mb增加到1024Mb。但它没有用。
然后我找到了解决方案如下:
删除/ var / lib / dpkg / updates中的所有文件,然后重试!!
无论如何它对我有用!
答案 1 :(得分:0)
我添加了一些任务来消除Ubuntu 16.04的dpkg问题,并且效果很好
tasks:
- name: configure dpkg 1
command: sudo rm /var/lib/apt/lists/lock
become: true
- name: configure dpkg 2
command: sudo rm /var/cache/apt/archives/lock
become: true
- name: configure dpkg 3
command: sudo rm /var/lib/dpkg/lock
become: true
- name: configure dpkg 4
command: sudo dpkg --configure -a
become: true
- name: Update and upgrade apt packages
become: true
apt:
upgrade: yes
update_cache: yes
cache_valid_time: 86400 #One day