From b3f7db200bc0da1492655a74adbe05d37ee5bccd Mon Sep 17 00:00:00 2001 From: Khue Doan Date: Mon, 15 Feb 2021 10:56:51 +0700 Subject: [PATCH] Add test playbook --- test/Makefile | 13 +++++++++++-- test/hosts.ini | 5 +++++ test/playbook.yml | 4 ++++ test/requirements.txt | 1 + 4 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 test/hosts.ini create mode 100644 test/playbook.yml create mode 120000 test/requirements.txt diff --git a/test/Makefile b/test/Makefile index b98c2a1c..c862e214 100644 --- a/test/Makefile +++ b/test/Makefile @@ -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 diff --git a/test/hosts.ini b/test/hosts.ini new file mode 100644 index 00000000..6324ef7e --- /dev/null +++ b/test/hosts.ini @@ -0,0 +1,5 @@ +[metal] +homelab ansible_host=192.168.64.5 ansible_user=ubuntu + +[etcd] +homelab diff --git a/test/playbook.yml b/test/playbook.yml new file mode 100644 index 00000000..4f282bca --- /dev/null +++ b/test/playbook.yml @@ -0,0 +1,4 @@ +- name: Install etcd for Terraform state + hosts: etcd + roles: + - { role: ../metal/roles/etcd, tag: etcd } diff --git a/test/requirements.txt b/test/requirements.txt new file mode 120000 index 00000000..c0199a7c --- /dev/null +++ b/test/requirements.txt @@ -0,0 +1 @@ +../metal/requirements.txt \ No newline at end of file