#!/usr/bin/env bash # To generate script: # ~/.local/bin/gengetoptions embed run_policy.sh.template > run_policy.sh # @getoptions parser_definition() { setup REST help:usage -- "Usage: run_policy [options]... [arguments]" '' msg -- 'Options:' flag FLAG_D -d --debug init:=0 -- "displays debug information" flag DRY_RUN -n --dry-run init:=0 -- "run a dry run" param POLICY -p --policy base:"default" -- "Policy to run (default: 'base')" disp :usage -h --help } # @gengetoptions parser -i parser_definition parse # # INSERTED HERE # # @end parse "$@" eval "set -- ${REST}" set -e # Ref: # https://medium.com/@emachnic/using-policyfiles-with-chef-client-local-mode-4f47477b24db ./scripts/export_policy.sh ${POLICY} echo -e "\n\e[4m\e[33mRunning:\e[0m \e[33m\e[1mchef-client -z\e[39m\e[0m" pushd policy-export > /dev/null if [ ${DRY_RUN} -eq 1 ]; then OPT="--why-run" fi if [ ${FLAG_D} -eq 1 ]; then OPT="${OPT} --log_level debug" fi bundle exec chef-client --chef-license 'accept' --config-option 'client_d_dir=../client.d' -z ${OPT} popd > /dev/null ./scripts/end_run.sh