我正在尝试使用Ansible设置一个涉及少量Ubuntu计算机的Vagrant环境,并且在编写Ansible Playbook以自动化该过程时遇到问题。首先,我按照这个答案的说明进行操作 - https://stackoverflow.com/a/26598887
以下是我从运行剧本中获得的错误摘录;
PLAY [web] ********************************************************************
GATHERING FACTS ***************************************************************
ok: [business-web1]
TASK: [Install MySQL] *********************************************************
failed: [business-web1] => (item=mysql-server) => {"failed": true, "item": "mysql-server"}
stderr: start: Job failed to start
invoke-rc.d: initscript mysql, action "start" failed.
dpkg: error processing package mysql-server-5.5 (--configure):
subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of mysql-server:
mysql-server depends on mysql-server-5.5; however:
Package mysql-server-5.5 is not configured yet.
dpkg: error processing package mysql-server (--configure):
dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
Errors were encountered while processing:
mysql-server-5.5
mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)
stdout: Reading package lists...
Building dependency tree...
Reading state information...
mysql-server is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 52 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up mysql-server-5.5 (5.5.44-0ubuntu0.14.04.1) ...
msg: '/usr/bin/apt-get -y -o "Dpkg::Options::=--force-confdef" -o "Dpkg::Options::=--force-confold" install 'mysql-server'' failed: start: Job failed to start
invoke-rc.d: initscript mysql, action "start" failed.
dpkg: error processing package mysql-server-5.5 (--configure):
subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of mysql-server:
mysql-server depends on mysql-server-5.5; however:
Package mysql-server-5.5 is not configured yet.
dpkg: error processing package mysql-server (--configure):
dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
Errors were encountered while processing:
mysql-server-5.5
mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)
FATAL: all hosts have already failed -- aborting
PLAY RECAP ********************************************************************
to retry, use: --limit @/home/vagrant/provision-business-mysql.retry
business-web1 : ok=1 changed=0 unreachable=0 failed=1
据我所知,看起来第一个“安装mysql”步骤没有运行。为了验证这一点,我设法通过直接从命令行运行ansible模块来重新创建问题;
vagrant@mgmt:~$ ansible web -m apt -a "name=mysql-server update_cache=yes cache_valid_time=3600 state=latest" --sudo
business-web1 | FAILED >> {
"failed": true,
"msg": "'/usr/bin/apt-get -y -o \"Dpkg::Options::=--force-confdef\" -o \"Dpkg::Options::=--force-confold\" install 'mysql-server'' failed: start: Job failed to start\ninvoke-rc.d: initscript mysql, action \"start\" failed.\ndpkg: error processing package mysql-server-5.5 (--configure):\n subprocess installed post-installation script returned error exit status 1\ndpkg: dependency problems prevent configuration of mysql-server:\n mysql-server depends on mysql-server-5.5; however:\n Package mysql-server-5.5 is not configured yet.\n\ndpkg: error processing package mysql-server (--configure):\n dependency problems - leaving unconfigured\nNo apport report written because the error message indicates its a followup error from a previous failure.\nErrors were encountered while processing:\n mysql-server-5.5\n mysql-server\nE: Sub-process /usr/bin/dpkg returned an error code (1)\n",
"stderr": "start: Job failed to start\ninvoke-rc.d: initscript mysql, action \"start\" failed.\ndpkg: error processing package mysql-server-5.5 (--configure):\n subprocess installed post-installation script returned error exit status 1\ndpkg: dependency problems prevent configuration of mysql-server:\n mysql-server depends on mysql-server-5.5; however:\n Package mysql-server-5.5 is not configured yet.\n\ndpkg: error processing package mysql-server (--configure):\n dependency problems - leaving unconfigured\nNo apport report written because the error message indicates its a followup error from a previous failure.\nErrors were encountered while processing:\n mysql-server-5.5\n mysql-server\nE: Sub-process /usr/bin/dpkg returned an error code (1)\n",
"stdout": "Reading package lists...\nBuilding dependency tree...\nReading state information...\nmysql-server is already the newest version.\n0 upgraded, 0 newly installed, 0 to remove and 52 not upgraded.\n2 not fully installed or removed.\nAfter this operation, 0 B of additional disk space will be used.\nSetting up mysql-server-5.5 (5.5.44-0ubuntu0.14.04.1) ...\n"
}
vagrant@mgmt:~$
我知道如何安装mysql并使用Ansible进行数据库设置?
答案 0 :(得分:4)
我尝试在新的ubuntu / trusty64框上安装mysql时遇到同样的错误。疯狂的原因是由于VM实例的内存少于512MB。确保您的Vagrantfile为您的VM分配足够的内存。
config.vm.provider "virtualbox" do |vb|
vb.memory = "512"
end
答案 1 :(得分:0)
@MicahElliott指向了正确的方向。该错误与ansible无关,但与apt相关。
E:子流程/ usr / bin / dpkg返回错误代码(1)
stdout:阅读包裹清单...... 构建依赖树... 阅读国家信息...... mysql-server已经是最新版本了。 0升级,0新安装,0删除,52未升级。 2未完全安装或移除。
在这里寻找解决方案:https://askubuntu.com/a/438843/231051