无法使用 Chef 中的部署资源部署 git 存储库
not able to deploy a git repo using deploy resource in chef
我很难使用 Chef 进行简单的 git 回购部署。
这是我的食谱:
deploy "tomatina" do
repo "git://github.com/visionmedia/express.git"
deploy_to '/tmp/selvam'
action :deploy
end
当我在节点上 运行 chef-client 时,它出错并显示文件未找到异常。我不确定错误是什么。我是 chef & ruby 的新手,不知道从哪里开始查看以跟踪错误。这是我的日志:
Starting Chef Client, version 12.9.41
resolving cookbooks for run list: ["myapp"]
Synchronizing Cookbooks:
- application_nodejs (2.0.1)
- build-essential (6.0.0)
- nodejs (1.3.0)
- apt (3.0.0)
- myapp (0.1.0)
- compat_resource (12.10.6)
- application (4.1.4)
Installing Cookbook Gems:
Compiling Cookbooks...
[2016-06-15T12:22:37+00:00] WARN: Chef::Provider::AptRepository already exists! Cannot create deprecation class for LWRP provider apt_repository from cookbook apt
[2016-06-15T12:22:37+00:00] WARN: AptRepository already exists! Deprecation class overwrites Custom resource apt_repository from cookbook apt
Converging 1 resources
Recipe: myapp::default
* deploy[tomatina] action deploy
- create new directory /tmp/selvam/shared
- clone from git://github.com/visionmedia/express.git into /tmp/selvam/shared/cached-copy
- checkout ref 31dd549f350accd7b4e3685c13f745e857557827 branch HEAD
- force ownership of /tmp/selvam to :
- deploy from repo to /tmp/selvam/releases
- force ownership of /tmp/selvam to :
- evaluate block and run any associated actions
================================================================================
Error executing action `deploy` on resource 'deploy[tomatina]'
================================================================================
Chef::Exceptions::FileNotFound
------------------------------
Cannot symlink /tmp/selvam/shared/config/database.yml to /tmp/selvam/releases/20160615122237/config/database.yml before migrate: No such file or directory @ sys_fail2 - (/tmp/selvam/shared/config/database.yml, /tmp/selvam/releases/20160615122237/config/database.yml)
Cookbook Trace:
---------------
/var/chef/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:41:in `run_action'
Resource Declaration:
---------------------
# In /var/chef/cache/cookbooks/myapp/recipes/default.rb
9: deploy "tomatina" do
10: repo 'git://github.com/visionmedia/express.git'
11: deploy_to '/tmp/selvam'
12: action :deploy
13: end
Compiled Resource:
------------------
# Declared in /var/chef/cache/cookbooks/myapp/recipes/default.rb:9:in `from_file'
deploy("tomatina") do
action [:deploy]
updated true
updated_by_last_action true
retries 0
retry_delay 2
default_guard_interpreter :default
deploy_to "/tmp/selvam"
repository_cache "cached-copy"
purge_before_symlink ["log", "tmp/pids", "public/system"]
create_dirs_before_symlink ["tmp", "public", "config"]
symlink_before_migrate {"config/database.yml"=>"config/database.yml"}
symlinks {"system"=>"public/system", "pids"=>"tmp/pids", "log"=>"log"}
revision "HEAD"
remote "origin"
scm_provider Chef::Provider::Git
keep_releases 5
enable_checkout true
checkout_branch "deploy"
declared_type :deploy
cookbook_name "myapp"
recipe_name "default"
repo "git://github.com/visionmedia/express.git"
shared_path "/tmp/selvam/shared"
destination "/tmp/selvam/shared/cached-copy"
current_path "/tmp/selvam/current"
end
Platform:
---------
x86_64-linux
Running handlers:
[2016-06-15T12:23:04+00:00] ERROR: Running exception handlers
Running handlers complete
[2016-06-15T12:23:04+00:00] ERROR: Exception handlers complete
Chef Client failed. 1 resources updated in 28 seconds
[2016-06-15T12:23:04+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2016-06-15T12:23:04+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2016-06-15T12:23:04+00:00] ERROR: deploy[tomatina] (myapp::default line 9) had an error: Chef::Exceptions::FileNotFound: Cannot symlink /tmp/selvam/shared/config/database.yml to /tmp/selvam/releases/20160615122237/config/database.yml before migrate: No such file or directory @ sys_fail2 - (/tmp/selvam/shared/config/database.yml, /tmp/selvam/releases/20160615122237/config/database.yml)
[2016-06-15T12:23:04+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
我的工作站、Chefserver 和节点是 运行ning ubuntu 16.04.
厨师详情:
Chef 开发套件版本:0.13.21
主厨客户端版本:12.9.41
伯克斯版本:4.3.2
厨房版本:1.7.3
大厨:12.9.41
错误很明显(重点是我的):
Cannot symlink /tmp/selvam/shared/config/database.yml to
/tmp/selvam/releases/20160615122237/config/database.yml before
migrate: No such file or directory @ sys_fail2 -
(/tmp/selvam/shared/config/database.yml,
/tmp/selvam/releases/20160615122237/config/database.yml)
您的存储库中没有 database.yml,因此部署资源无法为其创建 link。
部署资源中有一堆 callbacks,它在幕后做了很多事情。
让你头疼的是默认为 {"config/database.yml" => "config/database.yml"}
的 symlink_before_migrate
并且如部署资源属性中所述documentation:
Set to symlink_before_migrate({}) to prevent the creation of symbolic
links.
因此您的资源应该如下所示:
deploy "tomatina" do
repo "git://github.com/visionmedia/express.git"
deploy_to '/tmp/selvam'
symlink_before_migrate({})
action :deploy
end
但我强烈建议您先阅读部署资源的整个文档,了解它是如何工作的。
部署资源是一个非常小众的工具,可能不应该再使用了。您可能想要一个普通的 git
资源。
我很难使用 Chef 进行简单的 git 回购部署。
这是我的食谱:
deploy "tomatina" do
repo "git://github.com/visionmedia/express.git"
deploy_to '/tmp/selvam'
action :deploy
end
当我在节点上 运行 chef-client 时,它出错并显示文件未找到异常。我不确定错误是什么。我是 chef & ruby 的新手,不知道从哪里开始查看以跟踪错误。这是我的日志:
Starting Chef Client, version 12.9.41
resolving cookbooks for run list: ["myapp"]
Synchronizing Cookbooks:
- application_nodejs (2.0.1)
- build-essential (6.0.0)
- nodejs (1.3.0)
- apt (3.0.0)
- myapp (0.1.0)
- compat_resource (12.10.6)
- application (4.1.4)
Installing Cookbook Gems:
Compiling Cookbooks...
[2016-06-15T12:22:37+00:00] WARN: Chef::Provider::AptRepository already exists! Cannot create deprecation class for LWRP provider apt_repository from cookbook apt
[2016-06-15T12:22:37+00:00] WARN: AptRepository already exists! Deprecation class overwrites Custom resource apt_repository from cookbook apt
Converging 1 resources
Recipe: myapp::default
* deploy[tomatina] action deploy
- create new directory /tmp/selvam/shared
- clone from git://github.com/visionmedia/express.git into /tmp/selvam/shared/cached-copy
- checkout ref 31dd549f350accd7b4e3685c13f745e857557827 branch HEAD
- force ownership of /tmp/selvam to :
- deploy from repo to /tmp/selvam/releases
- force ownership of /tmp/selvam to :
- evaluate block and run any associated actions
================================================================================
Error executing action `deploy` on resource 'deploy[tomatina]'
================================================================================
Chef::Exceptions::FileNotFound
------------------------------
Cannot symlink /tmp/selvam/shared/config/database.yml to /tmp/selvam/releases/20160615122237/config/database.yml before migrate: No such file or directory @ sys_fail2 - (/tmp/selvam/shared/config/database.yml, /tmp/selvam/releases/20160615122237/config/database.yml)
Cookbook Trace:
---------------
/var/chef/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:41:in `run_action'
Resource Declaration:
---------------------
# In /var/chef/cache/cookbooks/myapp/recipes/default.rb
9: deploy "tomatina" do
10: repo 'git://github.com/visionmedia/express.git'
11: deploy_to '/tmp/selvam'
12: action :deploy
13: end
Compiled Resource:
------------------
# Declared in /var/chef/cache/cookbooks/myapp/recipes/default.rb:9:in `from_file'
deploy("tomatina") do
action [:deploy]
updated true
updated_by_last_action true
retries 0
retry_delay 2
default_guard_interpreter :default
deploy_to "/tmp/selvam"
repository_cache "cached-copy"
purge_before_symlink ["log", "tmp/pids", "public/system"]
create_dirs_before_symlink ["tmp", "public", "config"]
symlink_before_migrate {"config/database.yml"=>"config/database.yml"}
symlinks {"system"=>"public/system", "pids"=>"tmp/pids", "log"=>"log"}
revision "HEAD"
remote "origin"
scm_provider Chef::Provider::Git
keep_releases 5
enable_checkout true
checkout_branch "deploy"
declared_type :deploy
cookbook_name "myapp"
recipe_name "default"
repo "git://github.com/visionmedia/express.git"
shared_path "/tmp/selvam/shared"
destination "/tmp/selvam/shared/cached-copy"
current_path "/tmp/selvam/current"
end
Platform:
---------
x86_64-linux
Running handlers:
[2016-06-15T12:23:04+00:00] ERROR: Running exception handlers
Running handlers complete
[2016-06-15T12:23:04+00:00] ERROR: Exception handlers complete
Chef Client failed. 1 resources updated in 28 seconds
[2016-06-15T12:23:04+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2016-06-15T12:23:04+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2016-06-15T12:23:04+00:00] ERROR: deploy[tomatina] (myapp::default line 9) had an error: Chef::Exceptions::FileNotFound: Cannot symlink /tmp/selvam/shared/config/database.yml to /tmp/selvam/releases/20160615122237/config/database.yml before migrate: No such file or directory @ sys_fail2 - (/tmp/selvam/shared/config/database.yml, /tmp/selvam/releases/20160615122237/config/database.yml)
[2016-06-15T12:23:04+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
我的工作站、Chefserver 和节点是 运行ning ubuntu 16.04.
厨师详情:
Chef 开发套件版本:0.13.21
主厨客户端版本:12.9.41
伯克斯版本:4.3.2
厨房版本:1.7.3
大厨:12.9.41
错误很明显(重点是我的):
Cannot symlink /tmp/selvam/shared/config/database.yml to /tmp/selvam/releases/20160615122237/config/database.yml before migrate: No such file or directory @ sys_fail2 - (/tmp/selvam/shared/config/database.yml, /tmp/selvam/releases/20160615122237/config/database.yml)
您的存储库中没有 database.yml,因此部署资源无法为其创建 link。
部署资源中有一堆 callbacks,它在幕后做了很多事情。
让你头疼的是默认为 {"config/database.yml" => "config/database.yml"}
symlink_before_migrate
并且如部署资源属性中所述documentation:
Set to symlink_before_migrate({}) to prevent the creation of symbolic links.
因此您的资源应该如下所示:
deploy "tomatina" do
repo "git://github.com/visionmedia/express.git"
deploy_to '/tmp/selvam'
symlink_before_migrate({})
action :deploy
end
但我强烈建议您先阅读部署资源的整个文档,了解它是如何工作的。
部署资源是一个非常小众的工具,可能不应该再使用了。您可能想要一个普通的 git
资源。