Bitbucket 的 Puppet 代码管理器设置问题

Puppet Code Manager setup issue with Bitbucket

我刚刚安装了 puppet server enterprise 并成功添加了一些节点并获得了一些自定义模块 运行。我现在想在我们深入了解它之前转移到代码管理器。

我按照说明创建了一个空的 Bitbucket 存储库 here 并在 production 分支上用一个文件 environment.conf 对其进行了初始化,如 link 中所述.

然后我按照 here to configure Code Manager but when I get to Test the control repository 部分的步骤测试与 puppet-code deploy --dry-run 的连接,我收到以下错误:

--dry-run implies --all.
--dry-run implies --wait.
Dry-run deploying all environments.
2021/12/21 20:21:12 ERROR - [POST /deploys][500] Errors while collecting a list of environments to deploy (exit code: 1).
"/opt/puppetlabs/puppet/lib/ruby/gems/2.7.0/gems/rugged-0.27.7/lib/rugged/repository.rb:258: warning: Using the last argument as keyword parameters is deprecated\nERROR\t -\u003e Unable to determine current branches for Git source 'puppet' (/etc/puppetlabs/code-staging/environments)\nOriginal exception:\nFailed to authenticate SSH session: Unable to send userauth-publickey request at /opt/puppetlabs/server/data/code-manager/git/git@git.company.com-1234-in-puppet-control-repo.git\n"

我已将 puppet 服务器的 SSH 公钥添加到 bitbucket 存储库的访问令牌中。

我不完全理解该错误消息中的一些内容。

  1. Unable to determine current branches for Git source 'puppet' - 来源是什么意思 'puppet' - 我的仓库叫做 puppet-control-repo...?
  2. Failed to authenticate SSH session: Unable to send userauth-publickey request - 我的 puppet master 的 SSH 密钥在那个 repo 的令牌列表中,所以在这里也很困惑。

如有任何指导,我们将不胜感激。


更新 (13-01-2022):

我可以使用命令在 Puppet 服务器上成功克隆

git clone ssh://git@git.example.com:1234/project/puppet-control-repo.git --config core.sshCommand="ssh -i /etc/puppetlabs/puppetserver/ssh/id-control_repo.rsa"

注意确定木偶仍在返回的原因:

Failed to authenticate SSH session: Unable to send userauth-publickey request

我看到您在 ssh 目录中有一个 .pub 文件。我相信它在那里期待私钥。

您是否也将 master class 设置为指向您在 Puppet Enterprise web ui 中的存储库?

您需要在 class 上设置以下参数。

code_manager_auto_configure =   true
r10k_private_key = $PRIVATE_KEY_IN_SSH_FOLDER_ABSOLUTE_PATH
r10k_remote = Your git URL

可以在 PE Web 上的节点组中找到 PE Master UI Node Groups -> PE Infrastructure -> PE Master

我不知道你是否看到这里的说明 https://puppet.com/docs/pe/2021.4/control_repo.html#managing_environments_with_a_control_repository 但你可以 运行

puppet infrastructure configure 

确保文件具有正确的权限。

我还会测试尝试使用密钥克隆在代码部署之外工作

git clone -i /etc/puppetlabs/puppetserver/ssh/id-control_repo.rsa your_gir_url 

如果这有效,可能值得了解我们在 github https://puppet.com/blog/how-githubs-protocol-changes-impact-your-puppet-code-deployments/ 上遇到的一个问题,这取决于 bitbuckets 协议方法可能会产生类似的影响。

我们正在更新文档以推荐使用根据文章创建的更安全的密钥 ed25519。

如果手动克隆不起作用,则表明 bitbucket 没有正确的 public 密钥

另外一个更完整的调试命令是

runuser -u pe-puppet -- /opt/puppetlabs/puppet/bin/r10k -c /opt/puppetlabs/server/data/code-manager/r10k.yaml deploy environment production --puppetfile --verbose debug2

跟进

在调查中我们发现 https://support.puppet.com/hc/en-us/articles/227829007 显示在 r10k_remote 开始时需要 ssh:// 制作 ssh://git@[=38= 的示例命令]:davidsandilands/control-repo.git

我已请求更新 https://support.puppet.com/hc/en-us/articles/227829007 以强调这不是一个版本限制的问题,并要求更新 puppet 代码管理器配置文档以反映这可能是必需的。

感谢@david-sandilands 帮助我解决这个问题,并通过 puppet community slack 指导我阅读这篇文章。大佬!

编辑 1:

此处记录了解决方案:https://support.puppet.com/hc/en-us/articles/227829007-Fix-your-Bitbucket-Stash-Code-Manager-configuration-in-Puppet-Enterprise-2015-3-to-2017-2

但是该文档已过时,因为它也影响了版本 2021.4。

简而言之:

r10k_remote = "ssh://git@git.company.com:1234/project/control-repo.git"

没有

r10k_remote = "git@git.company.com:1234/project/control-repo.git"

使用 Bitbucket 服务器时。

编辑 2:

Puppet 已经更新了他们的文档: https://puppet.com/docs/pe/2021.5/code_mgr_config.html#code_mgr_enable