export_policy.sh 525 B

1234567891011121314151617
  1. #!/usr/bin/env bash
  2. set -e
  3. POLICY=${1:-"base"}
  4. echo -e "\n\e[4m\e[33mExporting policy:\e[0m \e[33m\e[1m${POLICY}\e[39m\e[0m"
  5. ssh-ident -V
  6. # Ref:
  7. # https://medium.com/@emachnic/using-policyfiles-with-chef-client-local-mode-4f47477b24db
  8. rm -rf policy-export/*
  9. echo -e "\e[32m"
  10. ln -svf "${POLICY}.rb" Policyfile.rb
  11. echo -en "\e[39m\e[0m"
  12. bundle exec chef-cli update "${POLICY}.rb"
  13. bundle exec chef-cli export "${POLICY}.rb" -f policy-export
  14. # pushd policy-export > /dev/null
  15. # tar xfz *.tgz && rm -rf *.tgz
  16. # popd > /dev/null