我正在尝试使用AWS OpsWorks部署Django应用程序。我对任何一种DevOps工作都是全新的,所以我遇到了相当大的困难。
我正在尝试使用这本食谱来自动化我的部署。我需要Python3.4,所以我修改了食谱中的一些内容。现在,在部署钩子期间,我从以下代码中得到一个错误:
# install requirements
requirements = Helpers.django_setting(deploy, 'requirements', node)
if requirements
Chef::Log.info("Installing using requirements file: #{requirements}")
pip_cmd = ::File.join(deploy["venv"], 'bin', 'pip')
execute "#{pip_cmd} install --source=#{Dir.tmpdir} -r #{::File.join(deploy[:deploy_to], 'current', requirements)}" do
cwd ::File.join(deploy[:deploy_to], 'current')
user deploy[:user]
group deploy[:group]
environment 'HOME' => ::File.join(deploy[:deploy_to], 'shared')
end
else
Chef::Log.debug("No requirements file found")
end错误报告:
STDERR: /opt/aws/opsworks/releases/20141216163306_33300020141216163306/vendor/bundle/ruby/2.0.0/gems/mixlib-shellout-1.4.0/lib/mixlib/shellout/unix.rb:147:in `chdir': No such file or directory - /srv/www/django/current (Errno::ENOENT)我知道这段代码试图从我的requirements.txt文件中安装需求,但是tmp目录和current目录是怎么回事?显然,当我进行部署时,没有创建current目录。对于从部署中拖入OpsWorks的代码来说,文件结构通常是什么样的?此外,我怎样才能找到解决这个错误的方法呢?
几天来,我一直在阅读关于主厨、OpsWorks、KitchenCI、Berksfile和其他技术的文档,只是觉得被DevOps世界的所有东西淹没了。我只想让我的应用程序运行!
编辑
习惯json是:
{
"deploy" : {
"django" : {
"django_settings_template" : null,
"django_settings_file" : "settings.py",
"django_collect_static" : "true",
"python_major_version" : "3.4",
"venv_options" : "--python=$(which python3.4) --no-site-packages",
"custom_type" : "django"
}
}
}发布于 2014-12-25 06:56:52
如果没有当前目录,那是因为它不是在部署期间创建的。您的脚本实际上引用了该目录。
下面这段代码是您出错的地方。如果您引用执行资源块execute.html上的文档,您将看到,如果不向执行资源提供命令,那么块的名称将是执行的命令。因此,在您的例子中,您是通过Ruby的file.join生成到pip命令的路径,所以pip_cmd应该类似于/usr/bin/pip,然后这个块的名称是命令,应该类似于
#Mind you I'm not sure if the /tmp dir is correct, but if not it might also be the chef tmp directory
/usr/bin/pip install --source=/tmp -r /srv/www/django/current/requirements现在在资源中有了cwd属性,它是“当前工作目录”或执行命令的目录。因此,当执行此命令时,它将在/srv/www/django/current中执行。
pip_cmd = ::File.join(deploy["venv"], 'bin', 'pip')
execute "#{pip_cmd} install --source=#{Dir.tmpdir} -r #{::File.join(deploy[:deploy_to], 'current', requirements)}" do
cwd ::File.join(deploy[:deploy_to], 'current')
user deploy[:user]
group deploy[:group]
environment 'HOME' => ::File.join(deploy[:deploy_to], 'shared')
end现在,如果不对您的部署有更多的了解,我就无法真正地告诉您如何在不了解更多您的部署的情况下修复它。你能发布你的实际食谱代码吗?这样我们就可以看到你是如何使用这个食谱来部署你的代码了吗?
{
'deploy': {
'django': {
'repository': 'Your github URL',
'revision': 'your revision number'
},
}
}https://stackoverflow.com/questions/27625836
复制相似问题