Add a Vagrant config for one PXE server and 3 clients

vagrant-lab
Stan Drozd 2019-01-10 21:04:28 +01:00
parent 4f908d7b0c
commit c990d465c6
No known key found for this signature in database
GPG Key ID: EB6D6A3C40C7521D
19 changed files with 163 additions and 0 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
*swp
*.log
.vagrant

72
Vagrantfile vendored Normal file
View File

@ -0,0 +1,72 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
# Supervisor node
config.vm.define "pope" do |pope|
pope.vm.box = "debian/jessie64"
pope.vm.hostname = "pxe-server"
#pope.ssh.username ='root'
#pope.ssh.insert_key = 'true'
#pope.ssh.forward_x11 = 'true'
#using rsync to fix nfs issues
pope.vm.synced_folder "vagrant-lab/pxe-server-config", "/config", type: "rsync"
pope.vm.network "private_network", ip: "192.168.0.254", libvirt__network_name: "pxe_network", :libvirt__dhcp_enabled => false, virtualbox__intnet: "pxe_network"
pope.vm.provider :libvirt do |libvirt|
libvirt.cpu_mode = 'host-passthrough'
libvirt.memory = '1024'
libvirt.cpus = '1'
end
pope.vm.provider :virtualbox do |vb|
vb.memory = '1024'
vb.cpus = '1'
vb.gui = false
end
pope.vm.provision "shell", path: "vagrant-lab/pxe-server-config/setup.sh"
end
# The blades
for i in 1..3
config.vm.define "cardinal#{i}" do |cardinal|
cardinal.vm.box = "ubuntu/bionic64"
cardinal.vm.boot_timeout = 0
# Handle PXE settings for libvirt
cardinal.vm.provider :libvirt do |libvirt|
libvirt.cpu_mode = 'host-passthrough'
libvirt.memory = '1024'
libvirt.cpus = '1'
libvirt.storage :file, :size => '10G', :type => 'qcow2'
libvirt.boot 'network'
libvirt.mgmt_attach = 'false'
libvirt.management_network_name = "pxe_network"
libvirt.management_network_address = "192.168.0.0/24"
libvirt.management_network_mode = "nat"
end
# Same for virtualbox
cardinal.vm.provider :virtualbox do |vb|
vb.memory = '1024'
vb.cpus = '1'
vb.gui = 'true'
vb.customize [
'modifyvm', :id,
'--nic1', 'intnet',
'--intnet1', 'pxe_network',
'--boot1', 'net',
'--boot2', 'none',
'--boot3', 'none',
'--boot4', 'none'
]
end
end
end
end

View File

@ -0,0 +1,15 @@
ddns-update-style none;
# option domain-name "example.org";
default-lease-time 600;
max-lease-time 7200;
authoritative;
log-facility local7;
subnet 192.168.0.0 netmask 255.255.255.0 {
range 192.168.0.10 192.168.0.20;
option domain-name-servers 192.168.0.254, 8.8.8.8;
next-server 192.168.0.254;
filename "pxelinux.0";
}

View File

@ -0,0 +1,21 @@
# Defaults for isc-dhcp-server initscript
# sourced by /etc/init.d/isc-dhcp-server
# installed at /etc/default/isc-dhcp-server by the maintainer scripts
#
# This is a POSIX shell fragment
#
# Path to dhcpd's config file (default: /etc/dhcp/dhcpd.conf).
#DHCPD_CONF=/etc/dhcp/dhcpd.conf
# Path to dhcpd's PID file (default: /var/run/dhcpd.pid).
#DHCPD_PID=/var/run/dhcpd.pid
# Additional options to start dhcpd with.
# Don't use options -cf or -pf here; use DHCPD_CONF/ DHCPD_PID instead
#OPTIONS=""
# On what interfaces should the DHCP server (dhcpd) serve DHCP requests?
# Separate multiple interfaces with spaces, e.g. "eth0 eth1".
INTERFACES="eth1"

Binary file not shown.

View File

@ -0,0 +1,12 @@
UI syslinux/vesamenu.c32
DEFAULT Local Boot
PROMPT 0
MENU INCLUDE syslinux/graphics.conf
MENU AUTOBOOT Local disk boot in # secondes ...
TIMEOUT 100
LABEL Local Boot
KERNEL syslinux/chain.c32
APPEND hd0

Binary file not shown.

After

Width:  |  Height:  |  Size: 757 KiB

Binary file not shown.

View File

@ -0,0 +1,19 @@
ALLOWOPTIONS 0
MENU RESOLUTION 800 600
MENU BACKGROUND syslinux/background.png
MENU ROWS 5
MENU MARGIN 30
MENU TIMEOUTROW 30
MENU COLOR BORDER * #00000000 #00000000 none
#MENU COLOR TITLE * #88ffffff #00000000 none
MENU COLOR UNSEL * #e0ffffff #00000000 none
MENU COLOR SEL * #e0ffffff #20ffffff all
MENU COLOR TABMSG * #00000000 #00000000 none
MENU COLOR TIMEOUT * #e0ff0000 #00000000 none
MENU COLOR TIMEOUT_MSG * #e0ffffff #00000000 none
MENU COLOR SCROLLBAR * #00000000 #00000000 none
TIMEOUT 50

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,4 @@
TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/tftpboot"
TFTP_ADDRESS="192.168.0.254:69"
TFTP_OPTIONS="--secure"

View File

@ -0,0 +1,19 @@
#!/bin/bash
### DHCPD configuration
apt-get install -y isc-dhcp-server
cp /config/resources/dhcpd.conf /etc/dhcp/dhcpd.conf
cp /config/resources/isc-dhcp-server /etc/default/isc-dhcp-server
systemctl restart isc-dhcp-server
### TFTPD configuration
apt-get install -y tftpd-hpa
cp /config/resources/tftpd-hpa /etc/default/tftpd-hpa
mkdir /tftpboot
cp -R /config/resources/pxelinux.cfg /tftpboot
cp -R /config/resources/syslinux /tftpboot
cp /config/resources/pxelinux.0 /tftpboot
systemctl restart tftpd-hpa
### PXE configuration
apt-get install -y pxe