Unattended Provisioning a VM with multiple disks

Hi,

I'm new to Foreman. I've installed Katello 2.3/Foreman 1.9.2 and everything
seems to work. Was able to unattended provision a RHEL 7 host in VMware
vSphere/vCenter. Works great (kudos to the people responsible for all
this!).

Now, I want to be able to provision a host with multiple disks. I was able
to do it by setting up a new kickstart partition table template. But I have
some questions:

Is it safe to assume that the order in which I add the disks in the
"Virtual Machine" tab will match up with the VM when it's created? For
example, will the first disk be "sda", the second disk be "sdb", etc?

If not, how do I set up the kickstart partition table template? When I run
my tests, I only set up two disks and they always seemed to work. But I'm
wondering if I was just lucky?

I was looking at setting up a dynamic template. My first test was to
generate basically the same thing as I did before but writing it to
/tmp/diskpart.cfg and that worked. But that success just makes me more
ambitious. So now, I'm wondering: can I set the mount point of these disks
somewhere in the Foreman gui and retrieve it in this dynamic template? The
"Name" field seems to be arbitrary so was thinking of entering the mount
point there. I was looking at the @host* variables in the "Template
Writing" document but there doesn't seem to be any variables that
correspond to the data in the Virtual Machine tab (i.e. "Data store",
"Name", and "Size (GB)"). Do they exist? If so, where are they documented?
If not documented, where would I look to find it?

Also, if I'm going about this all wrong, please let me know. And please
point me in the correct direction.

Thanks!

–Stephen

> Hi,
>
> I'm new to Foreman. I've installed Katello 2.3/Foreman 1.9.2 and everything
> seems to work. Was able to unattended provision a RHEL 7 host in VMware
> vSphere/vCenter. Works great (kudos to the people responsible for all
> this!).

Thanks! Welcome to the family!

> Now, I want to be able to provision a host with multiple disks. I was able
> to do it by setting up a new kickstart partition table template. But I have
> some questions:
>
> Is it safe to assume that the order in which I add the disks in the "Virtual
> Machine" tab will match up with the VM when it's created? For example, will
> the first disk be "sda", the second disk be "sdb", etc?

I think this is quite dependant on the particular compute resource
you're using. However, it's always worked for me.

> If not, how do I set up the kickstart partition table template? When I run
> my tests, I only set up two disks and they always seemed to work. But I'm
> wondering if I was just lucky?

As I say, it generally works this way, but I would stop short of
saying it's guaranteed. It might be reasonable to raise a feature
request about the possibility of adding some kind of labels to
volumes, for compute resources that suport it. Either that, or someone
is going to correct me about the fact that it already is guaranteed in
some way :wink:

> I was looking at setting up a dynamic template. My first test was to
> generate basically the same thing as I did before but writing it to
> /tmp/diskpart.cfg and that worked. But that success just makes me more
> ambitious. So now, I'm wondering: can I set the mount point of these disks
> somewhere in the Foreman gui and retrieve it in this dynamic template? The
> "Name" field seems to be arbitrary so was thinking of entering the mount
> point there. I was looking at the @host* variables in the "Template Writing"
> document but there doesn't seem to be any variables that correspond to the
> data in the Virtual Machine tab (i.e. "Data store", "Name", and "Size
> (GB)"). Do they exist? If so, where are they documented? If not documented,
> where would I look to find it?

In general you can use [1] which contains most of what we precreate
for users. Also, if you disable SafeMode in the settings, you have
access to all the Foreman models (note, this is called SafeMode for a
reason, be careful). This requires some Rails knowledge, so I'll not
dive into right away - let us know if you need help with that, or pop
into #theforeman on Freenode.

> Also, if I'm going about this all wrong, please let me know. And please
> point me in the correct direction.

Sounds fine to me :wink:

Greg
Foreman Community Lead
IRC: gwmngilfen

··· On 10 October 2015 at 02:22, Stephen Odo wrote:

Thanks for the reply Greg.

>In general you can use [1] which contains most of what we precreate
>for users. Also, if you disable SafeMode in the settings, you have
>access to all the Foreman models (note, this is called SafeMode for a
>reason, be careful). This requires some Rails knowledge, so I'll not
>dive into right away - let us know if you need help with that, or pop
>into #theforeman on Freenode.

If you can provide pointers to documentation or just where to look to find
out how to get this information, I would be grateful.

I'm using a VMware compute resource. And the "Template Writing" wiki
document doesn't mention anything about storage variables. It does discuss
variables for the network interfaces but nothing about disks. How does one
find out what variables are available?

Thanks again!

Hello Stephen,

I am looking for documents to implement same u did. Do u have any
documentation for it. It will be helpful.

thanks,Pradeep

··· On Saturday, October 10, 2015 at 12:28:23 PM UTC+5:30, Stephen Odo wrote: > > Hi, > > I'm new to Foreman. I've installed Katello 2.3/Foreman 1.9.2 and > everything seems to work. Was able to unattended provision a RHEL 7 host in > VMware vSphere/vCenter. Works great (kudos to the people responsible for > all this!). > > Now, I want to be able to provision a host with multiple disks. I was able > to do it by setting up a new kickstart partition table template. But I have > some questions: > > Is it safe to assume that the order in which I add the disks in the > "Virtual Machine" tab will match up with the VM when it's created? For > example, will the first disk be "sda", the second disk be "sdb", etc? > > If not, how do I set up the kickstart partition table template? When I run > my tests, I only set up two disks and they always seemed to work. But I'm > wondering if I was just lucky? > > I was looking at setting up a dynamic template. My first test was to > generate basically the same thing as I did before but writing it to > /tmp/diskpart.cfg and that worked. But that success just makes me more > ambitious. So now, I'm wondering: can I set the mount point of these disks > somewhere in the Foreman gui and retrieve it in this dynamic template? The > "Name" field seems to be arbitrary so was thinking of entering the mount > point there. I was looking at the @host* variables in the "Template > Writing" document but there doesn't seem to be any variables that > correspond to the data in the Virtual Machine tab (i.e. "Data store", > "Name", and "Size (GB)"). Do they exist? If so, where are they documented? > If not documented, where would I look to find it? > > Also, if I'm going about this all wrong, please let me know. And please > point me in the correct direction. > > Thanks! > > --Stephen >

> Thanks for the reply Greg.
>
>>In general you can use [1] which contains most of what we precreate
>>for users. Also, if you disable SafeMode in the settings, you have
>>access to all the Foreman models (note, this is called SafeMode for a
>>reason, be careful). This requires some Rails knowledge, so I'll not
>>dive into right away - let us know if you need help with that, or pop
>>into #theforeman on Freenode.
>
> If you can provide pointers to documentation or just where to look to find
> out how to get this information, I would be grateful.

I'm a fool - I forgot to attach the link. Sounds like you found the
Template Writing wiki

> I'm using a VMware compute resource. And the "Template Writing" wiki
> document doesn't mention anything about storage variables. It does discuss
> variables for the network interfaces but nothing about disks. How does one
> find out what variables are available?

It's true that we don't do a great job of documenting that stuff - the
wiki page is fairly complete, I think.

The issue you're going encounter is that I don't think we store the VM
attributes (cpu, ram, disks etc) once the creation process is
complete, which is going to block you. I've had a look around, and
think this is something that's going to be a feature request [1]

With that said, for completeness, here's how the advanced stuff works.
Once you get into the Rails models, it works a little differently.
Basically the ERB templates are evaluated by Foreman, so whatever you
could do in the Rails console you can do in a template - but because
you can do things like Host.delete, we normally lock it down to
acceptable methods. Just so you're aware :wink:

So the basic approach is to figure out the call you want on the
console and then add it to the template. For example, I might write a
template that gets the default gateway for every subnet:

<% host.interfaces.each do |int| -%>
subnet is <%= int.subnet.default_gateway %>
<% end -%>

Here "host" is pre-provided variable when the template is being
rendered, on the console you'd use something like "host =
Host.find_by_name('myhost.mydomain.com')".

Clearly, this is a power-user thing. Good luck, and shout if we can help more :slight_smile:

[1] Foreman

··· On 13 October 2015 at 05:45, Stephen Odo wrote: