From d8212d24e3c617211bcb8e4c55f5142811683b1b Mon Sep 17 00:00:00 2001 From: Khue Doan Date: Wed, 21 Jul 2021 03:08:09 +0700 Subject: [PATCH] Remove metal layer Cluster API in infra layer already handle bare metal machines --- metal/Makefile | 11 ------- metal/README.md | 8 ----- metal/ansible.cfg | 4 --- metal/hosts.yml | 9 ------ metal/main.yml | 10 ------- metal/roles/pxe-server/tasks/main.yml | 29 ------------------- .../pxe-server/templates/dhcp/Dockerfile | 9 ------ .../pxe-server/templates/dhcp/dhcpd.conf.j2 | 20 ------------- .../pxe-server/templates/docker-compose.yml | 6 ---- metal/roles/wake/tasks/main.yml | 11 ------- 10 files changed, 117 deletions(-) delete mode 100644 metal/Makefile delete mode 100644 metal/README.md delete mode 100644 metal/ansible.cfg delete mode 100644 metal/hosts.yml delete mode 100644 metal/main.yml delete mode 100644 metal/roles/pxe-server/tasks/main.yml delete mode 100644 metal/roles/pxe-server/templates/dhcp/Dockerfile delete mode 100644 metal/roles/pxe-server/templates/dhcp/dhcpd.conf.j2 delete mode 100644 metal/roles/pxe-server/templates/docker-compose.yml delete mode 100644 metal/roles/wake/tasks/main.yml diff --git a/metal/Makefile b/metal/Makefile deleted file mode 100644 index 35d8df82..00000000 --- a/metal/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -.POSIX: - -default: run - -run: - ansible-playbook \ - --inventory hosts.yml \ - main.yml - -lint: - ansible-lint --project-dir . diff --git a/metal/README.md b/metal/README.md deleted file mode 100644 index b7d4aedf..00000000 --- a/metal/README.md +++ /dev/null @@ -1,8 +0,0 @@ -# Bare-metal - -- Ansible renders the configuration file for each bare metal machine (like IP, hostname...) and the PXE server from [templates](./roles/pxe-boot/templates) -- The tools container creates sibling containers to build a PXE server (includes DHCP, TFTP and HTTP server) -- Ansible [wake the machines up](./roles/pxe-boot/tasks/wake.yml) using Wake on LAN -- The machine start the boot process, the OS get installed (through PXE server) and the machine reboots to the new operating system -- Ansible performs some basic configuration on the machine (like install Docker) -- Ansible creates a Terraform state backend and generates the configuration file for it diff --git a/metal/ansible.cfg b/metal/ansible.cfg deleted file mode 100644 index f81604ed..00000000 --- a/metal/ansible.cfg +++ /dev/null @@ -1,4 +0,0 @@ -[defaults] -host_key_checking=false -stdout_callback=debug -stderr_callback=debug diff --git a/metal/hosts.yml b/metal/hosts.yml deleted file mode 100644 index 92bd5a70..00000000 --- a/metal/hosts.yml +++ /dev/null @@ -1,9 +0,0 @@ -metal: - hosts: - metal0: {ansible_host: 192.168.1.110, mac: '00:23:24:d1:f3:f0'} - metal1: {ansible_host: 192.168.1.111, mac: '00:23:24:d1:f4:d6'} - metal2: {ansible_host: 192.168.1.112, mac: '00:23:24:e7:04:60'} - metal3: {ansible_host: 192.168.1.113, mac: '00:23:24:d1:f5:69'} - vars: - ansible_user: root - ansible_ssh_private_key_file: ~/.ssh/id_ed25519 diff --git a/metal/main.yml b/metal/main.yml deleted file mode 100644 index 4bc6a240..00000000 --- a/metal/main.yml +++ /dev/null @@ -1,10 +0,0 @@ -- name: Start PXE server - hosts: localhost - roles: - - pxe-server - -- name: Provision bare metal machines - hosts: metal - gather_facts: no - roles: - - wake diff --git a/metal/roles/pxe-server/tasks/main.yml b/metal/roles/pxe-server/tasks/main.yml deleted file mode 100644 index 3714b53c..00000000 --- a/metal/roles/pxe-server/tasks/main.yml +++ /dev/null @@ -1,29 +0,0 @@ -- name: Gather network facts - ansible.builtin.setup: - gather_subset: - - network - -- name: Create build directory - file: - path: "{{ item }}" - state: directory - loop: - - "{{ role_path }}/build" - -- name: Copy configs - copy: - src: "{{ role_path }}/templates/" - dest: "{{ role_path }}/build" - -- name: Render DHCP config - template: - src: dhcp/dhcpd.conf.j2 - dest: "{{ role_path }}/build/dhcp/dhcpd.conf" - -- name: Start ephemeral DHCP server - docker_compose: - project_src: "{{ role_path }}/build" - state: present - restarted: yes - build: yes - recreate: always diff --git a/metal/roles/pxe-server/templates/dhcp/Dockerfile b/metal/roles/pxe-server/templates/dhcp/Dockerfile deleted file mode 100644 index 38bb0713..00000000 --- a/metal/roles/pxe-server/templates/dhcp/Dockerfile +++ /dev/null @@ -1,9 +0,0 @@ -FROM alpine:3 - -RUN apk add dhcp - -RUN touch /var/lib/dhcp/dhcpd.leases - -COPY dhcpd.conf /etc/dhcp/dhcpd.conf - -CMD [ "dhcpd", "-f", "-cf", "/etc/dhcp/dhcpd.conf" ] diff --git a/metal/roles/pxe-server/templates/dhcp/dhcpd.conf.j2 b/metal/roles/pxe-server/templates/dhcp/dhcpd.conf.j2 deleted file mode 100644 index f2d3e354..00000000 --- a/metal/roles/pxe-server/templates/dhcp/dhcpd.conf.j2 +++ /dev/null @@ -1,20 +0,0 @@ -option space pxelinux; -option pxelinux.magic code 208 = string; -option pxelinux.configfile code 209 = text; -option pxelinux.pathprefix code 210 = text; -option pxelinux.reboottime code 211 = unsigned integer 32; -option architecture-type code 93 = unsigned integer 16; - -subnet {{ ansible_default_ipv4.network }} netmask {{ ansible_default_ipv4.netmask }} { - option routers {{ ansible_default_ipv4.gateway }}; - range {{ ansible_default_ipv4.gateway | ansible.netcommon.ipmath(1) }} {{ ansible_default_ipv4.broadcast | ansible.netcommon.ipmath(-1) }}; - - class "pxeclients" { - match if substring (option vendor-class-identifier, 0, 9) = "PXEClient"; - next-server {{ ansible_default_ipv4.address }}; - - if option architecture-type = 00:07 { - filename "ipxe.efi"; - } - } -} diff --git a/metal/roles/pxe-server/templates/docker-compose.yml b/metal/roles/pxe-server/templates/docker-compose.yml deleted file mode 100644 index fe4d41cf..00000000 --- a/metal/roles/pxe-server/templates/docker-compose.yml +++ /dev/null @@ -1,6 +0,0 @@ -version: "3" - -services: - dhcp: - build: ./dhcp - network_mode: host diff --git a/metal/roles/wake/tasks/main.yml b/metal/roles/wake/tasks/main.yml deleted file mode 100644 index 5b497597..00000000 --- a/metal/roles/wake/tasks/main.yml +++ /dev/null @@ -1,11 +0,0 @@ -- name: Send magic Wake-on-LAN packet - community.general.wakeonlan: - mac: "{{ hostvars[inventory_hostname]['mac'] }}" - delegate_to: localhost - -- name: Wait for the servers to comes up - wait_for: - host: '{{ ansible_host }}' - port: 22 - search_regex: OpenSSH - delegate_to: localhost