ANSIBLE_CMD = ansible-playbook

facts:
	ansible -m setup all

bootstrap-network:
	$(ANSIBLE_CMD) -l $(HOSTNAME) -e ansible_host=$(ANSIBLE_HOST) -t network --skip-tags network_restart playbook.yml

bootstrap-reboot:
	ssh -t -i ~/.ssh/ansible ansible@$(ANSIBLE_HOST) "sudo reboot" || true

bootstrap-init:
	$(ANSIBLE_CMD) -l $(HOSTNAME) -e ansible_user=graham -e ansible_host=$(ANSIBLE_HOST) -k -K bootstrap.yml

bootstrap-init-root:
	ANSIBLE_CONFIG=ansible-bootstrap.cfg $(ANSIBLE_CMD) -l $(HOSTNAME) -e ansible_user=root -e ansible_host=$(ANSIBLE_HOST) -e ansible_become=no bootstrap.yml

bootstrap: bootstrap-init bootstrap-network bootstrap-reboot

bootstrap-root: bootstrap-init-root bootstrap-network bootstrap-reboot

run-all:
	$(ANSIBLE_CMD) -l $(HOSTNAME) -e ansible_host=$(ANSIBLE_HOST) playbook.yml

install-ssh-key:
	ssh-copy-id $(ANSIBLE_HOST)

reboot:
	ssh -t -i ~/.ssh/ansible ansible@$(ANSIBLE_HOST) "sudo reboot"

install-collections:
	ansible-galaxy collection install -r requirements.yml --force
