2021-02-15 00:10:39 +07:00
|
|
|
.POSIX:
|
|
|
|
|
2021-02-15 02:22:59 +07:00
|
|
|
NAME = homelab
|
|
|
|
|
2021-02-15 10:56:51 +07:00
|
|
|
default: run ansible
|
|
|
|
|
2021-02-15 00:10:39 +07:00
|
|
|
run:
|
2021-02-15 02:22:59 +07:00
|
|
|
multipass list | grep $(NAME) \
|
2021-02-15 10:56:51 +07:00
|
|
|
|| multipass launch \
|
2021-02-15 00:10:39 +07:00
|
|
|
--cpus 4 \
|
|
|
|
--mem 8G \
|
|
|
|
--disk 64G \
|
|
|
|
--cloud-init ./multipass-cloud-init.yaml \
|
2021-02-15 02:22:59 +07:00
|
|
|
--name $(NAME) \
|
2021-02-15 00:10:39 +07:00
|
|
|
release:20.10
|
2021-02-15 10:56:51 +07:00
|
|
|
multipass exec homelab -- sed -i "$$ a\$(shell cat ~/.ssh/id_rsa.pub)" /home/ubuntu/.ssh/authorized_keys
|
2021-02-15 02:22:59 +07:00
|
|
|
|
|
|
|
stop:
|
|
|
|
multipass stop $(NAME)
|
2021-02-15 00:33:50 +07:00
|
|
|
|
|
|
|
clean:
|
2021-02-15 02:22:59 +07:00
|
|
|
multipass delete $(NAME)
|
2021-02-15 00:33:50 +07:00
|
|
|
multipass purge
|
2021-02-15 10:56:51 +07:00
|
|
|
|
|
|
|
ansible:
|
|
|
|
python3 -m venv .venv \
|
|
|
|
&& . .venv/bin/activate \
|
|
|
|
&& pip3 install --upgrade pip \
|
|
|
|
&& pip3 install -r requirements.txt \
|
|
|
|
&& ansible-playbook --inventory hosts.ini playbook.yml
|