export_policy.sh 381 B

123456789101112
  1. #!/usr/bin/env bash
  2. # Ref:
  3. # https://medium.com/@emachnic/using-policyfiles-with-chef-client-local-mode-4f47477b24db
  4. POLICY=${1:-"base"}
  5. rm -rf policy-export/*
  6. bundle exec chef-cli update "${POLICY}.rb"
  7. bundle exec chef-cli export "${POLICY}.rb" -a policy-export
  8. ln -svf "${POLICY}.rb" Policyfile.rb
  9. pushd policy-export > /dev/null
  10. tar xfz *.tgz && rm -rf *.tgz
  11. popd > /dev/null