2015-06-08 151 views
0

我正在與Vagrant和Ansible以及Virtualbox合作。 當我嘗試在ubuntu精確(14.04)盒子上安裝Apache時,Vagrant失敗。之後我改進了答案。Vagrant - Ansible錯誤安裝Apache

這似乎是一個已知的bug,但即使我正在安裝更新的版本,錯誤也會顯示出來。 我也試過here,但沒有運氣。

我該如何解決這個問題?

謝謝。


修訂ANSWER

這是Ansible任務。 版本1:

- name: Install Apache 
    sudo: yes 
    apt: pkg=apache2 state=latest 
    register: apache2_apt 

輸出:

failed: [default] => {"failed": true} 
stderr: E: Sub-process /usr/bin/dpkg returned an error code (1) 

stdout: Reading package lists... 
Building dependency tree... 
Reading state information... 
Suggested packages: 
    www-browser apache2-doc apache2-suexec-pristine apache2-suexec-custom 
The following NEW packages will be installed: 
    apache2 
0 upgraded, 1 newly installed, 0 to remove and 183 not upgraded. 
Need to get 0 B/146 kB of archives. 
After this operation, 460 kB of additional disk space will be used. 
(Reading database ... 52932 files and directories currently installed.) 
Unpacking apache2 (from .../apache2_2.4.12-1+deb.sury.org~precise+5_amd64.deb) ... 
dpkg: error processing /var/cache/apt/archives/apache2_2.4.12-1+deb.sury.org~precise+5_amd64.deb (--unpack): 
error setting ownership of `/var/www/html.dpkg-new': Operation not permitted 
Processing triggers for man-db ... 
Processing triggers for ureadahead ... 
Errors were encountered while processing: 
/var/cache/apt/archives/apache2_2.4.12-1+deb.sury.org~precise+5_amd64.deb 

msg: '/usr/bin/apt-get -y -o "Dpkg::Options::=--force-confdef" -o "Dpkg::Options::=--force-confold" install 'apache2'' failed: E: Sub-process /usr/bin/dpkg returned an error code (1) 


FATAL: all hosts have already failed -- aborting 

版本2:

- name: Install Apache 
    command: "sudo apt-get install apache2" 
    register: apache2_apt 

輸出:

failed: [default] => {"changed": true, "cmd": ["sudo", "apt-get", "install", "apache2"], "delta": "0:00:07.745095", "end": "2015-06-09 11:08:53.726031", "rc": 100, "start": "2015-06-09 11:08:45.980936", "warnings": []} 
stderr: E: Sub-process /usr/bin/dpkg returned an error code (1) 
stdout: Reading package lists... 
Building dependency tree... 
Reading state information... 
Suggested packages: 
    www-browser apache2-doc apache2-suexec-pristine apache2-suexec-custom 
The following NEW packages will be installed: 
    apache2 
0 upgraded, 1 newly installed, 0 to remove and 183 not upgraded. 
Need to get 0 B/146 kB of archives. 
After this operation, 460 kB of additional disk space will be used. 
(Reading database ... 52932 files and directories currently installed.) 
Unpacking apache2 (from .../apache2_2.4.12-1+deb.sury.org~precise+5_amd64.deb) ... 
dpkg: error processing /var/cache/apt/archives/apache2_2.4.12-1+deb.sury.org~precise+5_amd64.deb (--unpack): 
error setting ownership of `/var/www/html.dpkg-new': Operation not permitted 
Processing triggers for man-db ... 
Processing triggers for ureadahead ... 
ureadahead will be reprofiled on next reboot 
Errors were encountered while processing: 
/var/cache/apt/archives/apache2_2.4.12-1+deb.sury.org~precise+5_amd64.deb 

FATAL: all hosts have already failed -- aborting 
+0

你能展現ansible任務? –

+0

@AntonisChristofides我已經更新了我的答案。 – stuzzo

+0

它是版本1還是版本2,能夠提供您引用的消息? –

回答

0

有此

一些可能出現的問題
  • 你需要禁用的AppArmor或更好的添加規則,AppArmor的服務,爲有客座機內的腳本到/ var/WWW訪問能力
  • 沒有與主機權限的麻煩,在/ var/WWW夾。嘗試檢查用戶是否有權訪問本地文件夾,將其映射爲從主機到訪客的共享文件夾 - 可能需要爲主機上的本地用戶添加權限。
  • 嘗試使用ansible星系與修復搜索已創建的角色兩個以前的問題
+0

檢查我最後的評論,在我原來的問題。我認爲這不是一個Ansible問題,但我會嘗試從ansible-galaxy下載另一個角色。 – stuzzo