如何覆盖 octopus-deploy 的超市厨师食谱的 tentacle_install_location 路径?

How do I override octopus-deploy's supermarket chef cookbook's tentacle_install_location path?

我当前的设置:

我正在创建一本说明书,用于将 Octopus Deploy 触手安装到我公司的标准 VM 上。我创建了一本名为 "octopus-deploy-mk6" 的新本地食谱。 "mk6" 是我们公司的名称,我使用此方法来定义我公司的特定安装要求。我在名为 "octopus-deploy" 的超市社区食谱中添加了 Berksshelf 依赖项。这是 link 到 "octopus-deploy":

Octopus-deploy supermarket link

我在 chef-repo/metadata.rb 文件中通过 berksshelf depend 语句包含了超市食谱:

depends 'octopus-deploy', '~> 0.4.3'

我把它放在 chef-repo/cookbooks/octopus-deploy-mk6/recipes/default.rb 文件中的以下配方中(注意,我发现示例中的校验和不是'需要):


    octopus_deploy_tentacle 'Tentacle' do
      action :install
      version '3.1.5'
    end

当我执行 "berks install""berks update""knife cookbook upload octopus-deploy-mk6" 命令,它很好地安装了 Octopus Deploy Tentacle。食谱实际上超出了我的预期。感谢 Brent Montague(如果您碰巧读到了这篇文章)创建了这本食谱。

如果我的设置不正确,请随时告诉我,我是 Chef 的新手。

问题如下:

我们公司安装Octopus Deploy触手的标准是安装在:"C:\Program Files (x86)\Octopus\Tentacle",超市菜谱安装在"C:\Program Files\Octopus Deploy\Tentacle"。虽然我个人比较喜欢supermarket cookbook取的目录名,但是企业标准是放到x86目录和Octopus子目录下,我改不了标准。 如何覆盖默认的触手安装位置?

这个问题的简单解决方案是使用 "copy and paste reuse" 并将整个社区说明书复制到我的 octopus-deploy-mk6 说明书中,然后只更改下面提到的一个文件。但是,我宁愿不这样做,这样我就可以在将来对超市版本进行更新。

这是我到目前为止调试的内容:

我注意到超市社区食谱在 octopus-deploy/libraries/tentacle.rb 文件中有以下代码:


  module OctopusDeploy
  # A container to hold the tentacle values instead of attributes
  module Tentacle
  ...
    def tentacle_install_location
      'C:\Program Files\Octopus Deploy\Tentacle'
    end

我已经尝试在安装操作之前在 chef-repo/cookbooks/octopus-deploy-mk6/recipes/default.rb 文件中进行设置:


    OctopusDeploy.Tentacle.tentacle_install_location = 'C:\Program Files (x86)\Octopus\Tentacle'

但是并没有解决问题。我也尝试过向 chef-repo/cookbooks/octopus-deploy-mk6/attributes/default.rb 文件添加一个属性,但没有成功。据我了解,这种属性文件方法仅适用于覆盖另一本食谱设置的属性(而不是覆盖 ruby method/property)。

感谢您对此提供的任何帮助。我是 Chef 的新手,在 Whosebug 或 Google 上找不到任何其他帖子来回答这个问题(我可能对 Chef 太陌生,Ruby 不知道要搜索的术语)。

所以简短的回答:"you can't"。

为了更详细地解释,我们必须看看如何使用该辅助方法。您可以使用 monkey patch 来覆盖该帮助程序,语法会与您所拥有的不同,但无论如何它都无济于事,所以让我们继续前进。该方法似乎只在 the provider code, and both times it is to set the cwd for some snippets of PowerShell code. That path is never passed to the installer, which from what I can tell must be what is actually creating the directory. The install itself probably happens here 中使用过两次。要更改实际安装目标,您需要将其放入该资源的 MSI 安装选项中。我不太了解 Octopus Deploy,但我猜你可以查找所需的 msiexec 标志来完成它。不幸的是,由于这段代码的编写方式,您必须 fork 食谱才能在其中进行更改。我建议让它使用资源 属性,然后将其作为补丁提交回原始食谱。