我正在学习这个教程:http://www.gotealeaf.com/blog/chef-basics-for-rails-developers,他们让我们制作自己的食谱。下面的代码就是秘诀。问题出在以cookbook_file "id_rsa“开头并在# Add Github as known host,comment之前结束的代码块。通过将id_rsa和id_rsa.pub文件移到cookbook_file -stack/ files /id_rsa.pub/目录中,我可以越过cookbook_file "id_rsa“块和cookbook_file "id_rsa.pub”块,但现在它在尝试使用sudo_without_password块时会中断。令人惊讶的是,如果我在操作: create_if_missing块抛出的每个错误之后都提供vagrant,配置就会一直到cookbooks_file的“授权密钥”块,但它却卡在那里;即使在第一次出现错误的情况下提供之后也是如此。对发生的事情有什么想法吗?请尽可能地描述,我对devops相对较新,只知道流浪汉和厨师的一些细节。提前感谢!
execute "apt-get update" do
command "apt-get update"
end
# OS Dendencies
%w(git ruby-dev build-essential libsqlite3-dev libssl-dev).each do |pkg|
package pkg
end
# Deployer user, sudoer and with known RSA keys
user_account 'deployer' do
create_group true
end
group "sudo" do
action :modify
members "deployer"
append true
end
cookbook_file "id_rsa" do
source "id_rsa"
path "/home/deployer/.ssh/id_rsa"
group "deployer"
owner "deployer"
mode 0600
action :create_if_missing
end
cookbook_file "id_rsa.pub" do
source "id_rsa.pub"
path "/home/deployer/.ssh/id_rsa.pub"
group "deployer"
owner "deployer"
mode 0644
action :create_if_missing
end
# Allow sudo command without password for sudoers
cookbook_file "sudo_without_password" do
source "sudo_without_password"
path "/etc/sudoers.d/sudo_without_password"
group "root"
owner "root"
mode 0440
action :create_if_missing
end
# Authorize yourself to connect to server
cookbook_file "authorized_keys" do
source "authorized_keys"
path "/home/deployer/.ssh/authorized_keys"
group "deployer"
owner "deployer"
mode 0600
action :create
end
# Add Github as known host
ssh_known_hosts_entry 'github.com'
# Install Ruby Version
include_recipe 'ruby_build'
ruby_build_ruby '2.1.2'
link "/usr/bin/ruby" do
to "/usr/local/ruby/2.1.2/bin/ruby"
end
gem_package 'bundler' do
options '--no-ri --no-rdoc'
end
# Install Rails Application
include_recipe "runit"
application 'capistrano-first-steps' do
owner 'deployer'
group 'deployer'
path '/var/www/capistrano-first-steps'
repository 'git@github.com:gotealeaf/capistrano-first-steps.git'
rails do
bundler true
database do
adapter "sqlite3"
database "db/production.sqlite3"
end
end
unicorn do
worker_processes 2
end
end*编辑*
自从第一次写这个问题以来,我已经注释掉了sudo_without_password块,并且能够通过添加
ssh_keygen true添加到user_account“部署程序”块。
我还在rails-stack/ authorized_keys /default/中放了一个空的默认文件,这样可以帮助cookbook_file 'authorized_keys‘块无错误地运行。
现在,当vagrant/chef尝试提取示例代码库时,我收到此错误
==> default: [2014-12-04T22:44:18+00:00] ERROR: deploy_revision[capistrano-first-steps] (/tmp/vagrant-chef-3/chef-solo-2/cookbooks/application/providers/default.rb line 123) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '128'
==> default: ---- Begin output of git ls-remote "git@github.com:gotealeaf/capistrano-first-steps.git" "HEAD" ----
==> default: STDOUT:
==> default: STDERR: Warning: Permanently added the RSA host key for IP address '192.30.252.129' to the list of known hosts.
==> default: Permission denied (publickey).
==> default: fatal: Could not read from remote repository.
==> default:
==> default: Please make sure you have the correct access rights
==> default: and the repository exists.
==> default: ---- End output of git ls-remote "git@github.com:gotealeaf/capistrano-first-steps.git" "HEAD" ----
==> default: Ran git ls-remote "git@github.com:gotealeaf/capistrano-first-steps.git" "HEAD" returned 128
==> default: [2014-12-04T22:44:18+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)发布于 2014-12-06 02:01:37
答案很简单,在我记起我在puppet上遇到了类似的问题之后。出于某些原因,我不确定为什么要使用
git@github.com:gotealeaf/capistrano-first-steps.git不适合流浪汉/厨师/木偶。因此,我所做的就是将上面的代码行改为
https://github.com/gotealeaf/capistrano-first-steps就这样,我的盒子配置工作了,没有任何问题!
发布于 2014-12-05 19:33:28
您可能需要将application资源指向将用于克隆存储库的私钥。
application 'capistrano-first-steps' do
...
deploy_key lazy { File.read("/home/deployer/.ssh/id_rsa") }
...
endhttps://stackoverflow.com/questions/27302816
复制相似问题