Last active
September 12, 2019 13:26
-
-
Save sierra-tango-echo/5241affa5937604f59e146c738e00fed to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Variables | |
CLUSTER_INTERFACE="eth1" | |
CLUSTER_IP="10.10.0.1" | |
CLUSTER_NETWORK="10.10.0.0" | |
CLUSTER_NETMASK="255.255.0.0" | |
CLUSTER_CIDR="$(ipcalc -p 1.1.1.1 255.255.0.0 |sed 's/.*=//g')" | |
DHCP_MIN="10.10.200.0" | |
DHCP_MAX="10.10.200.255" | |
yum -y install vim dhcp tftp xinetd tftp-server syslinux syslinux-tftpboot httpd dnsmasq git | |
cat << EOF > /etc/sysconfig/network-scripts/ifcfg-$CLUSTER_INTERFACE | |
DEVICE=$CLUSTER_INTERFACE | |
ONBOOT=yes | |
TYPE=Ethernet | |
DEFROUTE=no | |
BOOTPROTO=static | |
IPADDR=$CLUSTER_IP | |
NETMASK=$CLUSTER_NETMASK | |
NETWORK=$CLUSTER_NETWORK | |
ZONE=cluster | |
PEERDNS=no | |
EOF | |
cat << EOF > /etc/httpd/conf.d/deployment.conf | |
<Directory /opt/flight/deployment/> | |
Options Indexes MultiViews FollowSymlinks | |
AllowOverride None | |
Require all granted | |
Order Allow,Deny | |
Allow from $CLUSTER_NETWORK/$CLUSTER_CIDR | |
</Directory> | |
Alias /deployment /opt/flight/deployment | |
EOF | |
mkdir -p /opt/flight/deployment | |
systemctl enable httpd | |
sed -ie "s/^.*disable.*$/\ disable = no/g" /etc/xinetd.d/tftp | |
mkdir -p /var/lib/tftpboot/{boot,pxelinux.cfg} | |
cat << EOF > /var/lib/tftpboot/pxelinux.cfg/default | |
DEFAULT menu | |
PROMPT 0 | |
MENU TITLE PXE Menu | |
TIMEOUT 100 | |
TOTALTIMEOUT 1000 | |
ONTIMEOUT local | |
LABEL local | |
MENU LABEL (local) | |
MENU DEFAULT | |
LOCALBOOT 0 | |
EOF | |
systemctl enable xinetd | |
systemctl enable dnsmasq | |
systemctl enable firewalld | |
firewall-offline-cmd --new-zone cluster | |
firewall-offline-cmd --set-target=ACCEPT --zone cluster | |
firewall-offline-cmd --zone cluster --add-interface $CLUSTER_INTERFACE | |
firewall-offline-cmd --set-default-zone=external #so that we masquerade over our internet facing device | |
cat << EOF > /etc/dhcp/dhcpd.conf | |
omapi-port 7911; | |
default-lease-time 43200; | |
max-lease-time 86400; | |
ddns-update-style none; | |
option domain-name-servers $CLUSTER_IP; | |
allow booting; | |
allow bootp; | |
option fqdn.no-client-update on; # set the "O" and "S" flag bits | |
option fqdn.rcode2 255; | |
option pxegrub code 150 = text ; | |
option space PXE; | |
option PXE.mtftp-ip code 1 = ip-address; | |
option PXE.mtftp-cport code 2 = unsigned integer 16; | |
option PXE.mtftp-sport code 3 = unsigned integer 16; | |
option PXE.mtftp-tmout code 4 = unsigned integer 8; | |
option PXE.mtftp-delay code 5 = unsigned integer 8; | |
option arch code 93 = unsigned integer 16; # RFC4578 | |
# PXE Handoff. | |
next-server $CLUSTER_IP; | |
filename "pxelinux.0"; | |
log-facility local7; | |
subnet $CLUSTER_NETWORK netmask $CLUSTER_NETMASK { | |
pool | |
{ | |
range $DHCP_MIN $DHCP_MAX; | |
} | |
option routers $CLUSTER_IP; | |
} | |
EOF | |
systemctl enable dhcpd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment