0

I'm new to chef. Recent days, I'm studying policy in chef. But the command "chef install " failed with error (Mixlib::ShellOut::ShellCommandFailed). Please have a look and kind help. Thanks Here's the details--

  1. I create a cookbook named sample with policy file --

    chef generate cookbook sample

    It created the cookbook folder successfully.

  2. Then I create a recipe -- e.rb -- in it --

    file '/tmp/e.sh' do content ' #!/bin/bash cat /tmp/e.log DT=date +%F" "%T echo $1" "${DT} >> /tmp/e.log ' mode '755' end

  3. Then cd back to the chef-repo folder, I create another cookbook -- policytest --

    chef generate cookbook policytest -P

    It completed too.

  4. This time, I modified the metadata.rb in policytest as --

    name 'policytest' maintainer 'The Authors' maintainer_email 'you@example.com' license 'All Rights Reserved' description 'Installs/Configures policytest' version '0.1.0' chef_version '>= 16.0'

    depends 'sample'

And the policyfile.rb --

name 'policytest'
default_source :supermarket
run_list 'policytest::default'

cookbook 'policytest', path: '.'
cookbook 'sample', path: '../sample'
  1. Then I uploaded both cookbooks --

    knife cookbook upload sample knife cookbook upload policytest

    All successfully completed.

  2. Then the error raised when I install the policy --

    C:\Work\chef-repo\cookbooks>chef install policytest\Policyfile.rb Building policy policytest Expanded run list: recipe[policytest::default] Caching Cookbooks... Installing policytest

    = 0.0.0 from path Installing sample >= 0.0.0 from path Error: Failed to generate Policyfile.lock Reason: (Mixlib::ShellOut::ShellCommandFailed) Expected process to exit with [0], but received '1' ---- Begin output of git symbolic-ref -q HEAD ---- STDOUT: STDERR: 'git' is not recognized as an internal or external command, operable program or batch file. ---- End output of git symbolic-ref -q HEAD ---- Ran git symbolic-ref -q HEAD returned 1

    I can't search the solution for this error. Please kind help me to get what's my error -- either the policy coding or the process I executed? Thanks in advance for any idea.

EisenWang
  • 189
  • 1
  • 10

1 Answers1

1

Looks like Git is not installed, Please install it or point it out in path.

Thirumoorthi
  • 508
  • 1
  • 6
  • 13
  • Yes. After installed a git to my win, issue fixed. But I'm curious -- why this chef install needs a git? I didn't connect my chef code to a repo on github then what does this git do in "chef install"? – EisenWang Jun 09 '22 at 09:15
  • This is because git is needed for chef cookbook generate command, and basically chef thought we have git installed in windows by default but we have to customise chefdk to install got if it is not installed – Thirumoorthi Jun 10 '22 at 10:24