Add test playbook

This commit is contained in:
Khue Doan 2021-02-15 10:56:51 +07:00
parent c349d2c994
commit b3f7db200b
4 changed files with 21 additions and 2 deletions

View File

@ -2,16 +2,18 @@
NAME = homelab
default: run ansible
run:
multipass list | grep $(NAME) \
|| multipass launch \
|| multipass launch \
--cpus 4 \
--mem 8G \
--disk 64G \
--cloud-init ./multipass-cloud-init.yaml \
--name $(NAME) \
release:20.10
multipass shell $(NAME)
multipass exec homelab -- sed -i "$$ a\$(shell cat ~/.ssh/id_rsa.pub)" /home/ubuntu/.ssh/authorized_keys
stop:
multipass stop $(NAME)
@ -19,3 +21,10 @@ stop:
clean:
multipass delete $(NAME)
multipass purge
ansible:
python3 -m venv .venv \
&& . .venv/bin/activate \
&& pip3 install --upgrade pip \
&& pip3 install -r requirements.txt \
&& ansible-playbook --inventory hosts.ini playbook.yml

5
test/hosts.ini Normal file
View File

@ -0,0 +1,5 @@
[metal]
homelab ansible_host=192.168.64.5 ansible_user=ubuntu
[etcd]
homelab

4
test/playbook.yml Normal file
View File

@ -0,0 +1,4 @@
- name: Install etcd for Terraform state
hosts: etcd
roles:
- { role: ../metal/roles/etcd, tag: etcd }

1
test/requirements.txt Symbolic link
View File

@ -0,0 +1 @@
../metal/requirements.txt