infra/ansible/Makefile
2025-05-30 13:24:38 -05:00

63 lines
1.7 KiB
Makefile

ANSIBLE_CMD = ansible-playbook
build-local:
docker build -t docker.nsnw.ca/ansible:local .
build-latest:
docker build -t docker.nsnw.ca/ansible:latest .
run-local:
docker run --rm -it -e ANSIBLE_SETUP_OPTIONS -e SSH_PRIVATE_KEY -e ANSIBLE_OPTIONS -e SKIP_SETUP -e SKIP_PLAYBOOK -v ${PWD}/run/fact_cache:/app/fact_cache docker.nsnw.ca/ansible:local
run-local-shell:
docker run --rm -it -e ANSIBLE_SETUP_OPTIONS -e SSH_PRIVATE_KEY -e ANSIBLE_OPTIONS -e SKIP_SETUP -e SKIP_PLAYBOOK docker.nsnw.ca/ansible:local /bin/bash
run-latest:
docker run --rm -it -e ANSIBLE_SETUP_OPTIONS -e SSH_PRIVATE_KEY -e ANSIBLE_OPTIONS -e SKIP_SETUP -e SKIP_PLAYBOOK docker.nsnw.ca/ansible:latest
push-latest:
docker push docker.nsnw.ca/ansible:latest
clean:
rm -rfv tmp
dirs:
mkdir -pv tmp/fact_cache
chmod a+rxw tmp/fact_cache
base-latest: build-base-latest push-base-latest
base-local: build-base-local
latest: build-latest push-latest
local: dirs build-local run-local
facts:
ansible -m setup all
bootstrap-network:
$(ANSIBLE_CMD) -l $(HOSTNAME) -e ansible_host=$(ANSIBLE_HOST) -t network --skip-tags network_restart general.yml
bootstrap-reboot:
ssh -i ~/.ssh/ansible ansible@$(ANSIBLE_HOST) -t "sudo reboot" || true
bootstrap-init:
$(ANSIBLE_CMD) -l $(HOSTNAME) -e ansible_user=graham -e ansible_host=$(ANSIBLE_HOST) -k -K bootstrap.yml
bootstrap: bootstrap-init bootstrap-network bootstrap-reboot
run-all:
$(ANSIBLE_CMD) -l $(HOSTNAME) -e ansible_host=$(ANSIBLE_HOST) general.yml
install-ssh-key:
ssh-copy-id $(ANSIBLE_HOST)
setup-user: install-ssh-key
./setup-user.sh install $(ANSIBLE_HOST)
reboot:
ssh -i ~/.ssh/ansible ansible@$(ANSIBLE_HOST) -t "sudo reboot"
qc-web:
$(ANSIBLE_CMD) -l qc_web -t caddy general.yml