feat(setup): add 'clean' subcommand to remove generated files
Add ./setup clean to remove: - inventory/hosts.yml and host_vars/web.yml - terraform/tfplan - scripts/__pycache__ - .DS_Store files
This commit is contained in:
parent
e2f732c0f5
commit
8da2501612
1 changed files with 12 additions and 1 deletions
13
setup
13
setup
|
|
@ -7,7 +7,7 @@ temp_vault_pass_file=""
|
|||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage: ./setup [--no-ansible] [--no-terraform|--ansible-only] [--] [terraform <args>]
|
||||
Usage: ./setup [--no-ansible] [--no-terraform|--ansible-only] [clean] [--] [terraform <args>]
|
||||
|
||||
Defaults:
|
||||
- Runs Terraform (plan/apply) in terraform/
|
||||
|
|
@ -18,6 +18,7 @@ Options:
|
|||
--no-ansible Run Terraform only (no Ansible).
|
||||
--no-terraform Skip Terraform; requires existing inventory/hosts.yml.
|
||||
--ansible-only Alias for --no-terraform.
|
||||
clean Remove generated files (inventory, tfplan, cache).
|
||||
--help Show this help.
|
||||
|
||||
Terraform passthrough:
|
||||
|
|
@ -44,6 +45,16 @@ if [[ "${1:-}" == "--help" ]] || [[ "${1:-}" == "-h" ]]; then
|
|||
exit 0
|
||||
fi
|
||||
|
||||
if [[ "${1:-}" == "clean" ]]; then
|
||||
echo "Cleaning up generated files..."
|
||||
rm -f inventory/hosts.yml inventory/host_vars/web.yml
|
||||
rm -f terraform/tfplan
|
||||
rm -rf scripts/__pycache__
|
||||
find . -name ".DS_Store" -delete 2>/dev/null || true
|
||||
echo "Cleanup complete."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ "${1:-}" == "--no-ansible" ]]; then
|
||||
run_ansible=false
|
||||
shift
|
||||
|
|
|
|||
Loading…
Reference in a new issue