Project

General

Profile

Actions

Bug #14958

closed

undefined method `mask' for nil:NilClass error

Added by Mostafa Yasin over 8 years ago. Updated over 7 years ago.

Status:
Rejected
Priority:
Normal
Assignee:
-
Category:
Templates
Target version:
-
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

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? >
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
$real
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? >
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
$real
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? >
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
$real
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


Related issues 1 (1 open0 closed)

Related to Foreman - Feature #17033: Add Network Teaming configuration for hostsNewActions
Actions #1

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.

Actions #2

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

Actions #3

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.

Actions #4

Updated by Marek Hulán about 8 years ago

  • Related to Feature #17033: Add Network Teaming configuration for hosts added
Actions #5

Updated by Anonymous over 7 years ago

  • Status changed from Need more information to Rejected

the usual checks in such a template are needed.

Actions

Also available in: Atom PDF