mirror of
https://github.com/xcat2/xcat-core.git
synced 2025-06-12 08:10:12 +00:00
Review recommended changes
This commit is contained in:
@ -1,51 +1,48 @@
|
||||
.. _Using-Postinstallscript-label:
|
||||
|
||||
Using Postinstall Script
|
||||
------------------------
|
||||
While generating the rootimage directory for diskless or statelite osimage with ``genimage``, you may want to customize the rootimage after the package installation. The `postinstall` attribute of the osimage definition provides a hook to run user specicied script(s) against the rootimage directory in non-chrooted mode.
|
||||
=========================
|
||||
Using postinstall scripts
|
||||
=========================
|
||||
While running ``genimage`` to generate diskless or statelite osimage, you may want to customize the root image after the package installation step. The ``postinstall`` attribute of the osimage definition provides a hook to run user specified script(s), in non-chroot mode, against the directory specified by ``rootimgdir`` attribute.
|
||||
|
||||
xCAT ships the default postinstall scripts for the diskless/statelite osimages created with ``copycds``, for example ::
|
||||
xCAT ships a default ``postinstall`` script for the diskless/statelite osimages that must be executed to ensure a successful provisioning of the OS: ::
|
||||
|
||||
>lsdef -t osimage -o rhels7.3-ppc64le-netboot-compute -i postinstall
|
||||
lsdef -t osimage -o rhels7.3-ppc64le-netboot-compute -i postinstall
|
||||
Object name: rhels7.3-ppc64le-netboot-compute
|
||||
postinstall=/opt/xcat/share/xcat/netboot/rh/compute.rhels7.ppc64le.postinstall
|
||||
|
||||
Notice: All the operations inside the default postinstall scripts are mandatory for the osimage provision. If you want to customize the postinstall script for an osimage, you should make sure the contents of default postinstall script are included. This can be done in either of the following ways:
|
||||
Customizing the ``postinstall`` script, can be done by either one of the methods below:
|
||||
|
||||
1. Append your own postinstall scripts by ``chdef -t osimage -o <osimage> -p postinstall=<comma seperated list of full paths to postinstall scipts>``
|
||||
2. Create your own postinstall script based on the default postinstall script, then ``chdef -t osimage -o <osimage> postinstall=<customized postinstall script>``
|
||||
* Append your own ``postinstall`` scripts ::
|
||||
|
||||
The following are some key points in Q/A format, that will help you understand the usage of postinstall scripts:
|
||||
chdef -t osimage -o <osimage> -p postinstall=/install/custom/postinstall/rh7/mypostscript
|
||||
|
||||
When will the postinstall scripts run?
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* Create your own ``postinstall`` script based on the default ``postinstall`` script ::
|
||||
|
||||
In general, the brief workflow of ``genimage`` is:
|
||||
cp /opt/xcat/share/xcat/netboot/rh/compute.rhels7.ppc64le.postinstall /install/custom/postinstall/rh7/mypostscript
|
||||
# edit /install/custom/postinstall/rh7/mypostscript
|
||||
chdef -t osimage -o <osimage> postinstall=/install/custom/postinstall/rh7/mypostscript
|
||||
|
||||
a) install the packages specified in package list under rootimage directory
|
||||
b) cumstomizing the rootimage directory, such as system configuration file generation/modification
|
||||
c) generate the initrd based on the rootimage directory
|
||||
Common questions about the usage of ``postinstall`` scripts:
|
||||
------------------------------------------------------------
|
||||
|
||||
The postinstall scripts are run in step b).
|
||||
When do ``postinstall`` scripts run?
|
||||
````````````````````````````````````
|
||||
|
||||
Are postinstall scripts run in chrooted mode under rootimage directory?
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
High level flow of ``genimage`` process:
|
||||
|
||||
No. Unlike postscripts & postbootscripts, the postinstall scripts are run in non-chrooted mode. In the postinstall scripts, all the paths of the directories and files are based on the "/" of the managememnt node. You can change the working directory to rootimage directory with ``cd $IMG_ROOTIMGDIR``. "$IMG_ROOTIMGDIR" is an environment variable exported by genimage containing the full path of the rootimage directory on management node.
|
||||
a) install the packages specified by ``pkglist`` into ``rootimgdir`` directory
|
||||
b) cumstomize the ``rootimgdir`` directory
|
||||
c) generate the initrd based on the ``rootimgdir`` directory
|
||||
|
||||
What are some of the environment variables available to my customized scripts?
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
The ``postinstall`` scripts are executed in step b).
|
||||
|
||||
Besides "$IMG_ROOTIMGDIR" mentioned above, ``genimage`` exports a batch of environment variables while postinstall scripts are run, which can be used in your customized scipts. ::
|
||||
Do ``postinstall`` scripts execute in chroot mode under ``rootimgdir`` directory?
|
||||
`````````````````````````````````````````````````````````````````````````````````
|
||||
|
||||
IMG_ARCH(The architecture of the osimage, such as "ppc64le","x86_64"),
|
||||
IMG_NAME(The name of the osimage, such as "rhels7.3-ppc64le-netboot-compute"),
|
||||
IMG_OSVER(The os release of the osimage, such as "rhels7.3","sles11.4"),
|
||||
IMG_KERNELVERSION(the "kernelver" attribute of the osimage),
|
||||
IMG_PROFILE(the profile of the osimage, such as "service","compute"),
|
||||
IMG_PKGLIST(the "pkglist" attribute of the osimage),
|
||||
IMG_PKGDIR(the "pkgdir" attribute of the osimage),
|
||||
IMG_OTHERPKGLIST(the "otherpkglist" attribute of the osimage),
|
||||
IMG_OTHERPKGDIR(the "otherpkgdir" attribute of the osimage),
|
||||
IMG_ROOTIMGDIR(the "rootimgdir" attribute of the osimage)
|
||||
No. Unlike postscripts and postbootscripts, the ``postinstall`` scripts are run in non-chroot environment, directly on the management node. In the postinstall scripts, all the paths of the directories and files are based on ``/`` of the managememnt node. To reference inside the ``rootimgdir``, use the ``$IMG_ROOTIMGDIR`` environment variable, exported by ``genimage``.
|
||||
|
||||
What are some of the environment variables available to my customized ``postinstall`` scripts?
|
||||
``````````````````````````````````````````````````````````````````````````````````````````````
|
||||
|
||||
Environment variables, available to be used in the ``postinstall`` scripts are listed in ``postinstall`` attribute section of :doc:`linuximage </guides/admin-guides/references/man5/linuximage.5>`
|
||||
|
@ -92,7 +92,7 @@ linuximage Attributes:
|
||||
|
||||
\ **postinstall**\
|
||||
|
||||
Only supported in diskless image only. The fully qualified name of the scripts running in non-chroot mode after the package installation but before initrd generation during genimage. If multiple scripts are specified, they should be seperated with comma ",". A set of osimage attributes are exported as the environment variables to be used in the postinstall scripts:
|
||||
Supported in diskless image only. The fully qualified name of the scripts running in non-chroot mode after the package installation but before initrd generation during genimage. If multiple scripts are specified, they should be seperated with comma ",". A set of osimage attributes are exported as the environment variables to be used in the postinstall scripts:
|
||||
|
||||
|
||||
.. code-block:: perl
|
||||
|
@ -313,7 +313,7 @@ osimage Attributes:
|
||||
|
||||
\ **postinstall**\ (linuximage.postinstall)
|
||||
|
||||
Only supported in diskless image only. The fully qualified name of the scripts running in non-chroot mode after the package installation but before initrd generation during genimage. If multiple scripts are specified, they should be seperated with comma ",". A set of osimage attributes are exported as the environment variables to be used in the postinstall scripts:
|
||||
Supported in diskless image only. The fully qualified name of the scripts running in non-chroot mode after the package installation but before initrd generation during genimage. If multiple scripts are specified, they should be seperated with comma ",". A set of osimage attributes are exported as the environment variables to be used in the postinstall scripts:
|
||||
|
||||
|
||||
.. code-block:: perl
|
||||
|
@ -774,7 +774,7 @@ passed as argument rather than by table value',
|
||||
otherpkglist => 'The fully qualified name of the file that stores non-distro package lists that will be included in the image. It could be set to multiple paths. The multiple paths must be separated by ",".',
|
||||
otherpkgdir => 'The base directory where the non-distro packages are stored. Only 1 local directory supported at present.',
|
||||
exlist => 'The fully qualified name of the file that stores the file names and directory names that will be excluded from the image during packimage command. It is used for diskless image only.',
|
||||
postinstall => 'Only supported in diskless image only. The fully qualified name of the scripts running in non-chroot mode after the package installation but before initrd generation during genimage. If multiple scripts are specified, they should be seperated with comma ",". A set of osimage attributes are exported as the environment variables to be used in the postinstall scripts:
|
||||
postinstall => 'Supported in diskless image only. The fully qualified name of the scripts running in non-chroot mode after the package installation but before initrd generation during genimage. If multiple scripts are specified, they should be seperated with comma ",". A set of osimage attributes are exported as the environment variables to be used in the postinstall scripts:
|
||||
|
||||
IMG_ARCH(The architecture of the osimage, such as "ppc64le","x86_64"),
|
||||
IMG_NAME(The name of the osimage, such as "rhels7.3-ppc64le-netboot-compute"),
|
||||
|
Reference in New Issue
Block a user