% begin_ohpc_run
% ohpc_comment_header Complete basic Warewulf setup for master node \ref{sec:setup_ww}
\begin{lstlisting}[language=bash,literate={-}{-}1,keywords={},upquote=true,keepspaces]

# Edit the warewulf.conf file to use appropriate interface and settings
[sms](*\#*) yq -y -i '.ipaddr = "'${sms_ip}'"' /etc/warewulf/warewulf.conf
[sms](*\#*) yq -y -i '.netmask = "'${internal_netmask}'"' /etc/warewulf/warewulf.conf
[sms](*\#*) yq -y -i '.network = "'${internal_network}'"' /etc/warewulf/warewulf.conf
[sms](*\#*) yq -y -i '.dhcp["range start"] = "'${internal_network}'"' /etc/warewulf/warewulf.conf
[sms](*\#*) yq -y -i '.dhcp["range end"] = "static"' /etc/warewulf/warewulf.conf
[sms](*\#*) yq -y -i '.dhcp.template = "static"' /etc/warewulf/warewulf.conf

# Edit the nodes.conf to mount /opt on boot
[sms](*\#*) perl -pi -e "s/defaults,noauto,nofail,ro/defaults,nofail,ro/" /etc/warewulf/nodes.conf

# Turn on debugging messages
[sms](*\#*) yq -y -i '.nodeprofiles.default.kernel.args -= ["quiet"]' /etc/warewulf/nodes.conf
[sms](*\#*) echo "log-debug" >> /etc/dnsmasq.d/ww4-debug.conf

# Enable and start the warewulfd service before using wwctl.
[sms](*\#*) systemctl enable --now warewulfd

# Create a new "nodes" profile and inherit the "default" profile
[sms](*\#*) wwctl profile add nodes --profile default --comment "Nodes profile"

# Create a new "nodeconfig" overlay to store node configuration files and use the syncuser overlay.
[sms](*\#*) wwctl overlay create nodeconfig
[sms](*\#*) wwctl profile set --yes nodes --system-overlays nodeconfig --runtime-overlays syncuser

# Set default network configuration
[sms](*\#*) wwctl profile set -y nodes --netname=default --netdev=${eth_provision}
[sms](*\#*) wwctl profile set -y nodes --netname=default --netmask=${internal_netmask}
[sms](*\#*) wwctl profile set -y nodes --netname=default --gateway=${ipv4_gateway}
[sms](*\#*) wwctl profile set -y nodes --netname=default --nettagadd=DNS=${dns_servers}

# Configuring Warewulf will restart/enable relevant services to support provisioning
[sms](*\#*) wwctl configure --all

# Generate ssh keys (usually generated on login)
[sms](*\#*) bash /etc/profile.d/ssh_setup.sh
\end{lstlisting}
% end_ohpc_run
