Remove metal layer

Cluster API in infra layer already handle bare metal machines
This commit is contained in:
Khue Doan 2021-07-21 03:08:09 +07:00
parent 489615d504
commit d8212d24e3
No known key found for this signature in database
GPG Key ID: 4C1A90A461B3C27B
10 changed files with 0 additions and 117 deletions

View File

@ -1,11 +0,0 @@
.POSIX:
default: run
run:
ansible-playbook \
--inventory hosts.yml \
main.yml
lint:
ansible-lint --project-dir .

View File

@ -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

View File

@ -1,4 +0,0 @@
[defaults]
host_key_checking=false
stdout_callback=debug
stderr_callback=debug

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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" ]

View File

@ -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";
}
}
}

View File

@ -1,6 +0,0 @@
version: "3"
services:
dhcp:
build: ./dhcp
network_mode: host

View File

@ -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