Puppet:Vcsrepo (git) 問題“....存在,但不是所需的存儲庫。”

Puppet:Vcsrepo (git) 問題“....存在,但不是所需的存儲庫。”

我使用 puppet/Vcsrepo 將軟體從 Bitbucket(雲端)伺服器分發和更新到一堆 Linux 伺服器。這種方法多年來一直運作良好,但大約 6 個月前,Puppet 開始抱怨Error: Path /usr/local/tools/... exists and is not the desired repository.每次運行時的每個儲存庫。我認為當我們從 Bitbucket 的本地版本遷移到雲端版本時,問題可能就開始了。

如果我刪除路徑並執行 puppet,它會替換該目錄,然後在下次運行時再次 barfs。當我需要更新時,我最終刪除了存儲庫。

傀儡程式碼已簡化為:

  define deploy(Array $names) {

    $names.each |$repo| {
      vcsrepo { "/usr/local/tools/$repo":
        ensure   => present,
        provider => git,
        user     => 'tools',
        source   => "https://[email protected]/uoa/$repo.git",
      }
    }

  }
  
.....

  $names_list = [
    'common-library',
    'common-tools'
  ]

  ...::deploy {"base-tools":
    names => $names_list,
  }

任何想法是什麼問題或如何診斷問題。

答案1

是的,git 的 CVE 補丁壞了您現有的配置。過去幾天它在 Debian Buster 上發布,導致系統 puppet (5.5.10-4) 出現損壞。似乎沒有適用於 vcsrepo 3.2.1(支援 Puppet 5 的最新版本)的補丁。我不確定為什麼我的 Bullseye 機器似乎沒有受到影響。

如果您可以升級到 Puppet 6,則目前的 vcsrepo 版本可以處理此問題。

如果沒有,作為解決方法,您可以執行以下操作:

一次:

      concat { '/etc/gitconfig' :
        owner   => 'root',
        group   => 'root',
        mode    => '0644',
      }

然後在每個循環內的定義:

      concat::fragment { "gitconfig_$repo" :
        target  => '/etc/gitconfig',
        content => "[safe]\n\tdirectory = /usr/local/tools/$repo\n\n",
        before  => Vcsrepo["/usr/local/tools/$repo"],
      }

相關內容