Git authentication in Chef

前端 未结 6 1552
眼角桃花
眼角桃花 2020-12-14 02:11

When deploying an application with Chef, I\'ve got the code base set to be cloned from a private github repository with the following resource:

git \'/mnt/ap         


        
6条回答
  •  生来不讨喜
    2020-12-14 02:30

    We use the similar setup for Mercurial, but it should be the same with Git, I hope.

    We use ssh keys to authenticate. The key is stored in encrypted databag (with newlines replaced by "\n"). First of all this private key is created on the node from databag.

    git_key = Chef::EncryptedDataBagItem.load( "private_keys", "git_key" )
    file "/some/path/id_rsa" do
      content git_key['private']
    end
    

    And then use it when connecting to git repository using ssh_wrapper:

    git "/opt/mysources/couch" do
      repository "git://git.apache.org/couchdb.git"
      reference "master"
      action :sync
      ssh_wrapper "ssh -i /some/path/id_rsa" #the path to our private key file
    end
    

提交回复
热议问题