【问题标题】:Vagrant chef-solo not finding cookbook file that existsVagrant chef-solo 找不到存在的食谱文件
【发布时间】:2015-04-05 14:13:33
【问题描述】:

我正在通过 vagrant 和 chef-solo 运行以下收据,其目的是克隆一个 GIT 存储库:

# Recipe that includes all dependencies
include_recipe "sesame::packages"
include_recipe "sesame::git_key"

# Create folders
directory node['sesame']['sourcecode_dir'] do
    owner node['sesame']['user']
    group node['sesame']['group']
    mode "0750"
    action :create
end

directory node['sesame']['temp_dir'] do
    owner node['sesame']['user']
    group node['sesame']['group']
    mode "0750"
    action :create
end

# Creating the SSH wrapper for git
cookbook_file "#{node['sesame']['temp_dir']}/git_ssh_wrapper.sh" do
    source "git_ssh_wrapper.sh"
    owner node["sesame"]["user"]
    group node["sesame"]["group"]
    mode "0755"
end

# Clone the git repo
git node['sesame']['sourcecode_dir'] do
    user node['sesame']['user']
    group node['sesame']['group']
    ssh_wrapper "#{node['sesame']['temp_dir']}/git_ssh_wrapper.sh"
    repository node['sesame']['git_repo']
    reference "master"
    action :sync
    timeout 9999
end

执行收据时遇到的错误是:

STDERR: error: cannot run /home/vagrant/tmp/git_ssh_wrapper.sh: No such file or directory

此文件对应于应该在食谱文件资源中创建的文件。

让我感到困惑的是,如果我 ssh 到机器,git_ssh_wrapper.sh 文件就在那里,所以我不明白为什么厨师抱怨它找不到它。

以防万一,我从 Windows 主机运行 Vagrant,但运行 chef 的机器是 Ubuntu 精确64。

感谢任何帮助。

最好的问候

丹尼尔

【问题讨论】:

  • 当您通过kitchen login 登录该框时,/home/vagrant/tmp/git_ssh_wrapper.sh 是实际路径/to/that/thing.sh 吗?
  • 我使用vagrant ssh box 登录,git_ssh_wrapper.sh 在那里。我注意到的是,这个配方是运行列表中的第一个配方,其中其他配方具有相似的结构,并尝试创建相同的文件来克隆其他 git 存储库。当我执行vagrant up 时,我看到一些关于此文件的WARN 消息,这些消息似乎与运行列表中的其他配方相关(尽管那些尚未执行)。我想如果在创建文件之前添加一个检查文件是否存在可能会有所帮助?

标签: git vagrant chef-infra


【解决方案1】:

我终于找到了问题所在。文件git_ssh_wrapper.sh 在那里,但没有正确执行。原因是我已将托管食谱的 git 存储库克隆到 Windows 主机,并且在此过程中,文件中插入了 DOS 行尾字符,这使得一旦厨师尝试执行它就会失败。

我必须在我的 Git 安装中添加以下配置行来克隆存储库而不插入 DOS 行尾:

git config --global core.autocrlf input

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-04-11
    • 1970-01-01
    • 2018-01-23
    • 2013-03-08
    • 2016-03-26
    • 2015-02-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多