From f8ffbe34526b9128d14f525a36e589a427ec20f3 Mon Sep 17 00:00:00 2001 From: BluemediaGER Date: Sun, 15 May 2022 14:25:38 +0200 Subject: [PATCH] Clean up roles and add makefile --- .gitignore | 1 + README.md | 5 ++--- metal/Makefile | 18 ++++++++++++++++++ metal/install-os.yml | 4 ++-- metal/inventories/lab.yml | 8 ++++---- metal/roles/pxe-cleanup/tasks/main.yml | 11 +++++++++++ metal/roles/pxe-teardown/tasks/main.yml | 5 ----- 7 files changed, 38 insertions(+), 14 deletions(-) create mode 100644 .gitignore create mode 100644 metal/Makefile create mode 100644 metal/roles/pxe-cleanup/tasks/main.yml delete mode 100644 metal/roles/pxe-teardown/tasks/main.yml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..600d2d3 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.vscode \ No newline at end of file diff --git a/README.md b/README.md index d63f8ec..6889fac 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # Homelab automation -This project contains the ansible and docker based automation of my homelab. The structure is inspired by [Khue Doan's Homelab Project](https://github.com/khuedoan/homelab). -The repo is currently work in progress. Nothing is tested yet, so everything could burst into flames at any time :) +This project contains the ansible and docker based automation of my homelab. The structure is inspired by [Khue Doan's Homelab Project](https://github.com/khuedoan/homelab). ## Hardware @@ -9,7 +8,7 @@ The repo is currently work in progress. Nothing is tested yet, so everything cou - CPU: `Intel Core i5-7500T @ 2.70 GHz` - RAM: `16 GB` - NVMe SSD: `256 GB` - - SATA SSD: `128 GB` + - SATA SSD: `225 GB` - 1 × Raspberry Pi 4 (4 GB) ## Current features diff --git a/metal/Makefile b/metal/Makefile new file mode 100644 index 0000000..f3946f7 --- /dev/null +++ b/metal/Makefile @@ -0,0 +1,18 @@ +.POSIX: + +default: os-install + +os-install: + ansible-playbook \ + --inventory inventories/lab.yml \ + --ask-vault-pass \ + install-os.yml + +cluster: + ansible-playbook \ + --inventory inventories/lab.yml \ + cluster.yml + +console: + ansible-console \ + --inventory inventories/lab.yml \ No newline at end of file diff --git a/metal/install-os.yml b/metal/install-os.yml index 5e8f7c7..ccaf2ac 100644 --- a/metal/install-os.yml +++ b/metal/install-os.yml @@ -9,8 +9,8 @@ roles: - wol-wake -- name: Tear down PXE stack +- name: Clean up playbook execution hosts: localhost gather_facts: false roles: - - pxe-teardown \ No newline at end of file + - pxe-cleanup \ No newline at end of file diff --git a/metal/inventories/lab.yml b/metal/inventories/lab.yml index b687f01..e17d518 100644 --- a/metal/inventories/lab.yml +++ b/metal/inventories/lab.yml @@ -2,9 +2,9 @@ metal: children: masters: hosts: - lab-mini-1: {ansible_host: 192.168.6.21, mac: '4c:52:62:1c:bf:6c', disk: '/dev/nvme0n1'} - lab-mini-2: {ansible_host: 192.168.6.22, mac: '4c:52:62:0f:09:6d', disk: '/dev/nvme0n1'} - lab-mini-3: {ansible_host: 192.168.6.23, mac: '4c:52:62:0f:0a:23', disk: '/dev/nvme0n1'} + lab-mini-1: {ansible_host: 192.168.6.21, mac: '4c:52:62:1c:bf:6c', disk: '/dev/sda'} + lab-mini-2: {ansible_host: 192.168.6.22, mac: '4c:52:62:0f:09:6d', disk: '/dev/sda'} + lab-mini-3: {ansible_host: 192.168.6.23, mac: '4c:52:62:0f:0a:23', disk: '/dev/sda'} workers: hosts: - lab-mini-4: {ansible_host: 192.168.6.24, mac: '90:1b:0e:f8:e8:af', disk: '/dev/nvme0n1'} \ No newline at end of file + lab-mini-4: {ansible_host: 192.168.6.24, mac: '90:1b:0e:f8:e8:af', disk: '/dev/sda'} \ No newline at end of file diff --git a/metal/roles/pxe-cleanup/tasks/main.yml b/metal/roles/pxe-cleanup/tasks/main.yml new file mode 100644 index 0000000..8ad9db7 --- /dev/null +++ b/metal/roles/pxe-cleanup/tasks/main.yml @@ -0,0 +1,11 @@ +- name: Tear down PXE stack + docker_compose: + project_name: "pxe" + project_src: "{{ playbook_dir }}/roles/pxe-server/files/" + state: absent + +- name: Remove preseed files + file: + path: "{{ playbook_dir }}/roles/pxe-server/files/data/preseed/{{ hostvars[item]['mac'] }}.cfg" + state: "absent" + loop: "{{ groups['metal'] }}" \ No newline at end of file diff --git a/metal/roles/pxe-teardown/tasks/main.yml b/metal/roles/pxe-teardown/tasks/main.yml deleted file mode 100644 index aea2810..0000000 --- a/metal/roles/pxe-teardown/tasks/main.yml +++ /dev/null @@ -1,5 +0,0 @@ -- name: Tear down PXE stack - docker_compose: - project_name: "pxe" - project_src: "{{ playbook_dir }}/roles/pxe-server/files/" - state: absent \ No newline at end of file