Provisioning template writing help

Hi All,

I'd like to do an if statement in my template to resolve the proper gateway
address and subnet mask based on what the @host.ip is.

Here's a provisioning template I have:
<?xml version="1.0" encoding="utf-8"?>
<specs>
<ComputerName><%= @host.shortname -%></ComputerName>
<IPAddress><%= @host.ip -%></IPAddress>
<SubnetMask>255.255.255.0</SubnetMask>
<Gateway>192.168.0.1</Gateway>
<DNS>192.168.0.1</DNS>
<AdapterName>Ethernet</AdapterName>
<AdapterDNSSuffix>contoso.net</AdapterDNSSuffix>
</specs>

Basically i have a few subnets that this template will be hopefully used
for.

for example: for @host.ip, if it falls between a certain range I want the
subnet mask to be say, 255.255.0.0 and the gateway to be 192.168.0.2, and a
different mask and gateway IP for another subnet, etc.

Is it possible to build that kind of logic into the provisioning template,
and if so, are there any examples?

> From: "Ryan Yee" <ryaneyee@gmail.com>
> To: "Foreman users" <foreman-users@googlegroups.com>
> Sent: Tuesday, December 8, 2015 8:18:21 PM
> Subject: [foreman-users] Provisioning template writing help
>
> Hi All,
>
> I'd like to do an if statement in my template to resolve the proper gateway
> address and subnet mask based on what the @host.ip is.
>
> Here's a provisioning template I have:
> <?xml version="1.0" encoding="utf-8"?>
> <specs>
> <ComputerName><%= @host.shortname -%></ComputerName>
> <IPAddress><%= @host.ip -%></IPAddress>
> <SubnetMask>255.255.255.0</SubnetMask>
> <Gateway>192.168.0.1</Gateway>
> <DNS>192.168.0.1</DNS>
> <AdapterName>Ethernet</AdapterName>
> <AdapterDNSSuffix>contoso.net</AdapterDNSSuffix>
> </specs>
>
> Basically i have a few subnets that this template will be hopefully used
> for.
>
> for example: for @host.ip, if it falls between a certain range I want the
> subnet mask to be say, 255.255.0.0 and the gateway to be 192.168.0.2, and a
> different mask and gateway IP for another subnet, etc.
>
> Is it possible to build that kind of logic into the provisioning template,
> and if so, are there any examples?

See TemplateWriting - Foreman

You can use if statements and some logic, but why not just use Subnets
in Foreman? You can already create a subnet and set all those values
and just reference e.g. <%= @host.subnet.gateway %> in your template.

··· ----- Original Message -----


You received this message because you are subscribed to the Google Groups
"Foreman users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to foreman-users+unsubscribe@googlegroups.com.
To post to this group, send email to foreman-users@googlegroups.com.
Visit this group at http://groups.google.com/group/foreman-users.
For more options, visit https://groups.google.com/d/optout.

Thanks stephen, that looks like exactly where I want to build my logic
from.

Apologies, pretty newb at Foreman and its inner workings.

··· On Tuesday, December 8, 2015 at 6:39:18 PM UTC-8, stephen wrote: > > > > ----- Original Message ----- > > From: "Ryan Yee" <ryan...@gmail.com > > > To: "Foreman users" <forema...@googlegroups.com > > > Sent: Tuesday, December 8, 2015 8:18:21 PM > > Subject: [foreman-users] Provisioning template writing help > > > > Hi All, > > > > I'd like to do an if statement in my template to resolve the proper > gateway > > address and subnet mask based on what the @host.ip is. > > > > Here's a provisioning template I have: > > <?xml version="1.0" encoding="utf-8"?> > > > > <%= @host.shortname -%> > > <%= @host.ip -%> > > 255.255.255.0 > > 192.168.0.1 > > 192.168.0.1 > > Ethernet > > contoso.net > > > > > > Basically i have a few subnets that this template will be hopefully used > > for. > > > > for example: for @host.ip, if it falls between a certain range I want > the > > subnet mask to be say, 255.255.0.0 and the gateway to be 192.168.0.2, > and a > > different mask and gateway IP for another subnet, etc. > > > > Is it possible to build that kind of logic into the provisioning > template, > > and if so, are there any examples? > > See http://projects.theforeman.org/projects/foreman/wiki/templatewriting > > You can use if statements and some logic, but why not just use Subnets > in Foreman? You can already create a subnet and set all those values > and just reference e.g. <%= @host.subnet.gateway %> in your template. > > > > > > -- > > You received this message because you are subscribed to the Google > Groups > > "Foreman users" group. > > To unsubscribe from this group and stop receiving emails from it, send > an > > email to foreman-user...@googlegroups.com . > > To post to this group, send email to forema...@googlegroups.com > . > > Visit this group at http://groups.google.com/group/foreman-users. > > For more options, visit https://groups.google.com/d/optout. > > >

> Thanks stephen, that looks like exactly where I want to build my logic
> from.
>
> Apologies, pretty newb at Foreman and its inner workings.

No problem, for CentOS/RHEL we actually will configure all the network
stuff for you, but it's pretty basic for SuSE. It'd be really useful if
someone would convert the kickstart network snippet[1] into however
AutoYAST does it.

[1] https://github.com/theforeman/community-templates/blob/develop/snippets/kickstart_networking_setup.erb

··· On Wed, Dec 09, 2015 at 09:27:40AM -0800, Ryan Yee wrote:

On Tuesday, December 8, 2015 at 6:39:18 PM UTC-8, stephen wrote:

----- Original Message -----

From: “Ryan Yee” <ryan...@gmail.com <javascript:>>
To: “Foreman users” <forema...@googlegroups.com <javascript:>>
Sent: Tuesday, December 8, 2015 8:18:21 PM
Subject: [foreman-users] Provisioning template writing help

Hi All,

I’d like to do an if statement in my template to resolve the proper
gateway
address and subnet mask based on what the @host.ip is.

Here’s a provisioning template I have:

<?xml version="1.0" encoding="utf-8"?> <%= @host.shortname -%> <%= @host.ip -%> 255.255.255.0 192.168.0.1 192.168.0.1 Ethernet contoso.net

Basically i have a few subnets that this template will be hopefully used
for.

for example: for @host.ip, if it falls between a certain range I want
the
subnet mask to be say, 255.255.0.0 and the gateway to be 192.168.0.2,
and a
different mask and gateway IP for another subnet, etc.

Is it possible to build that kind of logic into the provisioning
template,
and if so, are there any examples?

See TemplateWriting - Foreman

You can use if statements and some logic, but why not just use Subnets
in Foreman? You can already create a subnet and set all those values
and just reference e.g. <%= @host.subnet.gateway %> in your template.


You received this message because you are subscribed to the Google
Groups
"Foreman users" group.
To unsubscribe from this group and stop receiving emails from it, send
an
email to foreman-user...@googlegroups.com <javascript:>.
To post to this group, send email to forema...@googlegroups.com
<javascript:>.
Visit this group at http://groups.google.com/group/foreman-users.
For more options, visit https://groups.google.com/d/optout.


Best Regards,

Stephen Benjamin
Red Hat Engineering