diff --git a/Makefile b/Makefile index 06dbe5c..92082f5 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,9 @@ CWD=$(abspath $(patsubst %/,%,$(dir $(abspath $(lastword $(MAKEFILE_LIST)))))) COMPRESSION_LEVEL ?= 5 +ANSIBLE_LIMIT ?= qemumachine +ANSIBLE_TAGS ?= + qemu_ifname_br = brlabsync qemu_ifname_tap = taplabsync qemu_hostname = qemumachine @@ -71,6 +74,25 @@ images/debian-stretch.torrent: images "$(DOCKER_IMAGE)" \ debian-stretch +.PHONY: ansible +ansible: + docker run \ + --rm \ + -v "${PWD}/packer/ansible:/ansible" \ + -e "user=`id -u`" \ + -e "group=`id -g`" \ + -e "ANNOUNCE=$(ANNOUNCE)" \ + -e "WEBSEED=$(WEBSEED)" \ + -e "TASK=ansible" \ + -v "${SSH_AUTH_SOCK}:/var/run/ssh_auth_sock" \ + -e "SSH_AUTH_SOCK=/var/run/ssh_auth_sock" \ + "$(DOCKER_IMAGE)" \ + -i inventories \ + $(if $(ANSIBLE_TAGS),-t $(ANSIBLE_TAGS),) \ + -l $(ANSIBLE_LIMIT) \ + --ssh-extra-args="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" \ + playbook.yml + # updates the initramfs # only used for development images/debian-stretch.initramfs.dev: tmp/initramfs-extracted/debian-stretch packer/initramfs/labsync diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index b365b70..aadd840 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -88,4 +88,8 @@ fi if [ -z "$TASK" ] || [ "$TASK" == "torrent" ]; then make_torrent "$NAME.squashfs" fi +if [ "$TASK" == "ansible" ]; then + cd /ansible + /usr/bin/ansible-playbook "$@" +fi