OpenVZ Forum


Home » General » Support » Customizing templates
Customizing templates [message #22903] Wed, 07 November 2007 09:33 Go to next message
tauren is currently offline  tauren
Messages: 7
Registered: November 2007
Junior Member
I'm a newbie here and am slightly confused with building custom templates. I've been reading the wiki, manual, and forum all day but haven't found the answers I seek. Maybe I missed them, or maybe I'm not understanding something fundamental, but I could use help.

I have created a FC6 HN and would like to install multiple identical FC6 VEs into it. I've already got fedora-core-6-i386-minimal and fedora-core-6-i386-default up and running.

However, what I really want is an easy way to create custom VEs without having to manually customize it each time I create one. I need to add several packages to each VE I create. I also need to make several customizations to configuration files for every VE.

I can add packages by going into the VE and running "yum install whatever". Or I could use vzyum from the HN. I can edit the config files within the VE. But once I've created a "custom" VE, how do I then take that VE and turn it into a template? It seems like this would be a very common request, but the solution eludes me.

I've discovered that I can customize the RPM list that is in a template. I copied minimal.list to custom.list and then added several rpms to it. Then I ran vzpkgcache on it.

[root@pyrite /]# cd /vz/template/fedora-core/6/i386/config
[root@pyrite config]# cp minimal.list custom.list
[root@pyrite config]# vi custom.list
[root@pyrite config]# vzpkgcache fedora-core-6-custom

Is that the best way to customize the RPMs that are included in a template? It seems like a good solution, but is this the recommended way?

But then what about the configuration changes I want to make? Is the best solution to edit install-post, install-pre, and update-post with commands to make the appropriate edits? What if I only want those edits for the custom template, not minimal or default?

And making the scripts to do all those edits could be time consuming. Is there a simpler way to just create a VE, manually make the edits, and then use that VE to create a template? But I do want a template that can be updated. This is what I'm trying to figure out.

Thanks!
Tauren




Re: Customizing templates [message #22925 is a reply to message #22903] Wed, 07 November 2007 15:09 Go to previous messageGo to next message
alticon-brian is currently offline  alticon-brian
Messages: 27
Registered: February 2006
Location: Washington, DC
Junior Member
Tauren,

I know that the way that you're mentioning is exactly how we do it.

Specifically, we have a few custom templates that include things like Plesk pre-configured to work inside of a VPS so we can speed up deployment.

That being said, you'll possibly be able to streamline down your configuration editing by throwing some sed magic into your install-post, just a thought.

--Brian
Re: Customizing templates [message #22940 is a reply to message #22925] Wed, 07 November 2007 17:55 Go to previous messageGo to next message
tauren is currently offline  tauren
Messages: 7
Registered: November 2007
Junior Member
alticon-brian wrote on Wed, 07 November 2007 10:09

Tauren,

I know that the way that you're mentioning is exactly how we do it.

Specifically, we have a few custom templates that include things like Plesk pre-configured to work inside of a VPS so we can speed up deployment.

That being said, you'll possibly be able to streamline down your configuration editing by throwing some sed magic into your install-post, just a thought.

--Brian


Thanks Brian, it helps to have this confirmed. So, to clarify, the following method is the suggested way to customize templates:

1. Edit minimal.list, default.list, or create your own custom.list file in a template's config directory. Add all of the desired packages into that file.

2. Modify the install-post script with the appropriate commands to perform any customizations/configurations necessary in the system. As Brian suggests, sed is your friend.

3. Build the template with vzpkgcache.

Can some others confirm that this is the preferred/best way to accomplish what I would like to do. I'd like to add this information to the wiki because I think it would help others. But if there are other ways to do it, I'd like to include that information in the wiki as well.

Lastly, does anyone know if there is a way to make parts of install-post exclusive to a certain install type? For instance, only apply certain commands if custom.list was used? I suppose I could test for the install of certain RPMs (rpm -q) before issuing the sed commands.

Thanks again,
Tauren
Re: Customizing templates [message #22942 is a reply to message #22940] Wed, 07 November 2007 18:16 Go to previous messageGo to next message
alticon-brian is currently offline  alticon-brian
Messages: 27
Registered: February 2006
Location: Washington, DC
Junior Member
You could always make your own version of {fedora,centos,redhat}-release which adds an additional line to the /etc/issue file. You could also package a separate RPM (which should be simple enough) which provides /etc/ve_issue where ve_issue contains the template name, then simply act on what the name is in ve_issue.

--Brian
Re: Customizing templates [message #22973 is a reply to message #22942] Thu, 08 November 2007 18:33 Go to previous messageGo to next message
tauren is currently offline  tauren
Messages: 7
Registered: November 2007
Junior Member
alticon-brian wrote on Wed, 07 November 2007 13:16

You could always make your own version of {fedora,centos,redhat}-release which adds an additional line to the /etc/issue file. You could also package a separate RPM (which should be simple enough) which provides /etc/ve_issue where ve_issue contains the template name, then simply act on what the name is in ve_issue.

--Brian


Good ideas. Thanks!

I was chatting in IRC about this topic and it was suggested that I simply create a VE based on a minimal template, start it and enter it, then add packages and perform all configuration changes I need to do. Once it is working, I exit and stop the VE. Then I tarball up the /vz/private/veid folder and put the tarball into /vz/template/cache. Then I can create new VEs from that template.

That sounds like a very simple way to accomplish what I need to do. But are there any drawbacks to that method? Are there advantages to creating a custom.list file and adding commands to install-post? Does one method make updating VEs and/or templates easier?

Thanks again!
Tauren
Re: Customizing templates [message #22974 is a reply to message #22973] Thu, 08 November 2007 18:49 Go to previous message
alticon-brian is currently offline  alticon-brian
Messages: 27
Registered: February 2006
Location: Washington, DC
Junior Member
Tauren,

I hope there's not too many drawbacks to this... I do it all the time. Smile

--Brian
Previous Topic: *SOLVED* Live-Migration and SYSV message queues
Next Topic: Howto build a template whith anaconda insted of rpmstrap
Goto Forum:
  


Current Time: Sun Aug 03 03:52:10 GMT 2025

Total time taken to generate the page: 1.05067 seconds