Bug #14958
closedundefined method `mask' for nil:NilClass error
Description
Greetings,
I have created a template to configure teaming during the provisioning process as follows:-
<%= snippet 'Kickstart_CentOS' %>
%post
<% subnet = @host.subnet ->
< myinterface = @host.interfaces.managed.first %>
cat << EOF > /etc/hostname
<%= myinterface.name %>
EOF
cat << EOF >> /etc/hosts
<%= myinterface.ip > <= myinterface.name > <= myinterface.shortname %>
EOF
cat << EOF > /etc/sysconfig/network-scripts/ifcfg-team0
DEVICE="team0"
DEVICETYPE="Team"
ONBOOT="yes"
BOOTPROTO="none"
NETMASK=<%= myinterface.subnet.mask >
IPADDR=<= myinterface.ip >
GATEWAY=<= myinterface.subnet.gateway >
SEARCH=<= @host.domain >
DNS1=<= subnet.dns_primary >
< if !subnet.dns_secondary.nil? && !subnet.dns_secondary.empty? >$real
DNS2=<= subnet.dns_secondary >
< end ->
TEAM_CONFIG='{"runner": {"name": "activebackup"}}'
EOF
real=`ip -o link | grep -i <= myinterface.mac -> | awk '{print $2;}' | sed s/://`
cat << EOF > /etc/sysconfig/network-scripts/ifcfg
DEVICE="$real"
DEVICETYPE="TeamPort"
ONBOOT=yes
BOOTPROTO="none"
TEAM_MASTER="team0"
EOF
< myinterface = @host.interfaces.second >
real=`ip o link | grep -i <= myinterface.mac -> | awk '{print $2;}' | sed s/://`
cat << EOF > /etc/sysconfig/network-scripts/ifcfg$real
DEVICE="$real"
DEVICETYPE="TeamPort"
ONBOOT=yes
BOOTPROTO="none"
TEAM_MASTER="team0"
EOF
cat << EOF > /etc/sysconfig/network-scripts/ifcfg-team1
DEVICE="team1"
DEVICETYPE="Team"
ONBOOT="yes"
BOOTPROTO="none"
NETMASK=<= myinterface.subnet.mask >
IPADDR=<= myinterface.ip >
GATEWAY=<= myinterface.subnet.gateway >
SEARCH=<= @host.domain >
DNS1=<= subnet.dns_primary >
< if !subnet.dns_secondary.nil? && !subnet.dns_secondary.empty? >$real
DNS2=<= subnet.dns_secondary >
< end ->
TEAM_CONFIG='{"runner": {"name": "activebackup"}}'
EOF
real=`ip -o link | grep -i <= myinterface.mac -> | awk '{print $2;}' | sed s/://`
cat << EOF > /etc/sysconfig/network-scripts/ifcfg
DEVICE="$real"
DEVICETYPE="TeamPort"
ONBOOT=yes
BOOTPROTO="none"
TEAM_MASTER="team1"
EOF
< myinterface = @host.interfaces.second >
real=`ip o link | grep -i <= myinterface.mac -> | awk '{print $2;}' | sed s/://`
cat << EOF > /etc/sysconfig/network-scripts/ifcfg$real
DEVICE="$real"
DEVICETYPE="TeamPort"
ONBOOT=yes
BOOTPROTO="none"
TEAM_MASTER="team1"
EOF
cat << EOF > /etc/sysconfig/network-scripts/ifcfg-team2
DEVICE="team2"
DEVICETYPE="Team"
ONBOOT="yes"
BOOTPROTO="none"
NETMASK=<= myinterface.subnet.mask >
IPADDR=<= myinterface.ip >
GATEWAY=<= myinterface.subnet.gateway >
SEARCH=<= @host.domain >
DNS1=<= subnet.dns_primary >
< if !subnet.dns_secondary.nil? && !subnet.dns_secondary.empty? >$real
DNS2=<= subnet.dns_secondary >
< end ->
TEAM_CONFIG='{"runner": {"name": "activebackup"}}'
EOF
real=`ip -o link | grep -i <= myinterface.mac -> | awk '{print $2;}' | sed s/://`
cat << EOF > /etc/sysconfig/network-scripts/ifcfg
DEVICE="$real"
DEVICETYPE="TeamPort"
ONBOOT=yes
BOOTPROTO="none"
TEAM_MASTER="team2"
EOF
< myinterface = @host.interfaces.second >
real=`ip o link | grep -i <= myinterface.mac -%> | awk '{print $2;}' | sed s/://`
cat << EOF > /etc/sysconfig/network-scripts/ifcfg$real
DEVICE="$real"
DEVICETYPE="TeamPort"
ONBOOT=yes
BOOTPROTO="none"
TEAM_MASTER="team2"
EOF
%end
And then I have added the MACs in "Interface" tab during creating "new host".
Please i get this error when trying to view the kickstart template using web interface "There was an error rendering the Kickstart BM Netcard for 6 NICs template: undefined method `mask' for nil:NilClass"
Regards,
Mostafa
Updated by Dominic Cleal over 8 years ago
- Category set to Templates
- Status changed from New to Need more information
If mask is called on a nil value, it sounds like your interface is missing a subnet. Ensure every interface you're managing has a subnet assigned.
Updated by Mostafa Yasin over 8 years ago
Thanks a lot, Dominic for your support.
I am a little bit confused about your editing. Could you please send me what i should put in the Teaming template.
Regards,
mostafa
Updated by Dominic Cleal over 8 years ago
I wasn't suggesting to edit the template, but to ensure your host's interfaces all have a subnet set.
Updated by Marek Hulán about 8 years ago
- Related to Feature #17033: Add Network Teaming configuration for hosts added
Updated by Anonymous over 7 years ago
- Status changed from Need more information to Rejected
the usual checks in such a template are needed.