0

I have found on the web that we can clone git repository from following chef resource block.

git "/path/to/check/out/to" do
  repository "git://github.com/opscode/chef.git"
  reference "master"
  action :sync
end

My question is how to use my Git user credentials in this resource block.

DominikAngerer
  • 6,354
  • 5
  • 33
  • 60
hlesnt395
  • 603
  • 10
  • 30
  • Possible duplicate of [Git authentication in Chef](https://stackoverflow.com/questions/20470076/git-authentication-in-chef) – DominikAngerer Sep 26 '17 at 10:39
  • Mostly not a dup because there is a better answer after 4 years, though SO likes to pretend old questions actually get updated but we all know they mostly don't. – coderanger Sep 26 '17 at 18:23

2 Answers2

0

Looking at the docu for chef you can add the ssh_wrapper parameter for this https://docs.chef.io/resource_git.html which will allow you to clone with a certain user.

Possible ssh_wrapper

your ssh_wrapper could look like:

ssh_wrapper "ssh -i /some/path/id_rsa"

All Parameters

git 'name' do
  additional_remotes         Hash
  checkout_branch            String
  depth                      Integer
  destination                String # defaults to 'name' if not specified
  enable_checkout            TrueClass, FalseClass
  enable_submodules          TrueClass, FalseClass
  environment                Hash
  group                      String, Integer
  notifies                   # see description
  provider                   Chef::Provider::Scm::Git
  reference                  String
  remote                     String
  repository                 String
  revision                   String
  ssh_wrapper                String
  subscribes                 # see description
  timeout                    Integer
  user                       String, Integer
  action                     Symbol # defaults to :sync if not specified
end
DominikAngerer
  • 6,354
  • 5
  • 33
  • 60
  • I'm agree with you on this. So there is noway that I can use the user credentials rather than using the SSH? I was thinking a way of that I can use secret databag for this. that's why. – hlesnt395 Sep 27 '17 at 07:04
  • Couldn't find normal credentials in their documentation or in a 10-20 min google + stackoverflow search - so I guess - SSH is the way to go for that. – DominikAngerer Sep 27 '17 at 08:32
0

If you want to use an SSH key as the credentials, check out the poise_git cookbook and resource, it handles that for you.

coderanger
  • 52,400
  • 4
  • 52
  • 75