From e8a98665b60238b1b5a0401dcc33bcb67b1559e4 Mon Sep 17 00:00:00 2001 From: Marc Cataford Date: Sun, 13 Oct 2024 16:31:30 -0400 Subject: [PATCH] build: replace scripts with more concise makefile --- Dockerfile | 9 +++++++++ README.md | 6 +++++- bootstrap.sh | 3 --- makefile | 27 +++++++++++++++++++++++++++ run.sh | 9 --------- 5 files changed, 41 insertions(+), 13 deletions(-) create mode 100644 Dockerfile delete mode 100755 bootstrap.sh create mode 100644 makefile delete mode 100755 run.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..126e076 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM debian:bookworm + +COPY . . + +RUN apt update && apt install pipx -y + +ENV PATH="$PATH:/root/.local/bin" + +CMD ./run.sh ./home.yml diff --git a/README.md b/README.md index 5d85828..acbbdaf 100644 --- a/README.md +++ b/README.md @@ -2,4 +2,8 @@ Environment tweaks for (my) everyday happiness. -Do the thing, it will do the needful: `./run.sh ` +Do the thing, it will do the needful: `make configure-env PLAY=`. + +## Development + +Repository prerequisites can be installed and validated via `make bootstrap` and containerized playbook tests can be run via `make test`. diff --git a/bootstrap.sh b/bootstrap.sh deleted file mode 100755 index e90b121..0000000 --- a/bootstrap.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -pipx run pre-commit install diff --git a/makefile b/makefile new file mode 100644 index 0000000..5155cf3 --- /dev/null +++ b/makefile @@ -0,0 +1,27 @@ +HELPTEXT="\ + help: \n\ + \tshows this helpful text.\n\ + bootstrap: \n\ + \tensures that repository-specific prerequisites are installed. \n\ + test:\n\ + \truns the playbook in a containerized environment for validation \n\ + configure-env:\n\ + \truns the playbook specified by PLAY on the host.\n\ + " +.PHONY: help +help: + @echo $(HELPTEXT) + +.PHONY: bootstrap +bootstrap: + pipx run pre-commit install + +.PHONY: test +test: + podman build . -t env-ansible-test + podman run env-ansible-test + +.PHONY: configure-env +configure-env: + pipx install "ansible-core" + ansible-playbook -v --ask-become-pass $(PLAY) diff --git a/run.sh b/run.sh deleted file mode 100755 index f88b66e..0000000 --- a/run.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -if [[ -z "$(command -v pipx)" ]]; then - echo -e "\033[31;1mThis expects pipx to be installed.\033[0m" - exit 1 -fi - -pipx install "ansible-core" -ansible-playbook -v --ask-become-pass "$1"