1

I am using Chef 12.0.3 for managing servers. Earlier I was using application cookbook for cloning repository. But now in higher version of application cookbook, this support is moved to new cookbook application_git.

Issue:

  1. I want to change the path of deploy key
  2. Contents of ssh_wrapper
  3. Path of ssh_wrapper.

What I have tried (Current code):

application 'accounts' do
  action :deploy
  path <somepath>
  owner 'nobody'
  group 'nogroup'
  git 'name' do
    repository <repopath>
    revision <value>
    deploy_key deploy_key
 end
end 

I am not able to find if I need to pass path using ssh_wrapper_path or ssh_wrapper or deploy_key_path. All are failing.

Currently, I am able to get keys and wrapper but at a wrong place.

1 Answer 1

1

Quoting from the cookbook README:

deploy_key – SSH key to use with git. Can be specified either as a path to key file already created or as a string value containing the key directly.

And:

The application_git resource deploys code from git. It extends the core git resource to support deploy keys and disabling strict host key verification.

So checking the core git resource documentation:

ssh_wrapper Ruby Type: String

The path to the wrapper script used when running SSH with git. The GIT_SSH environment variable is set to this.

so something like this (untested) should do (using the wrapper in the cookbook) :

cookbook_file '/path/to/my/desired/ssh_wrapper.sh' do
  source 'my_ssh_wrapper.sh'
end

application 'accounts' do
  action :deploy
  path <somepath>
  owner 'nobody'
  group 'nogroup'
  git 'name' do
    repository <repopath>
    revision <value>
    ssh_wrapper '/path/to/my/desired/ssh_wrapper.sh'
    deploy_key deploy_key
 end
end 

You can of course do the same with the deploy_key, but using something like chef_vault or an encrypted databag sounds better to avoid commiting deploy keys within the cookbook.

2
  • Ssh_wrapper change will work with this. But main issue is for deploy_key path
    – Arora20
    May 29, 2018 at 5:10
  • 1
    What is the problem using another cookbook_file resource for deploy_key ?
    – Tensibai
    May 29, 2018 at 7:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.