Wednesday, November 26, 2014

Oracle Solaris 11 Derived Manifest with Automated Installation

I have been looking at Derived Manifest recently so that I can have one manifest to control the installation of Oracle Solaris 11.2 FCS on our dual boot desktops.

Ref:

Derived Manifest

As you know the manifest controls how Solaris is installed on the system (disk layout, locales, software) , so I use the following manifest to install Solaris on to 2nd partition of windows desktops.

The script is run at install time (by a non-privileged user aiuser plus the additional privileges  solaris.network.autoconf.read, solaris.smf.read.*) and it will be passed some defined variable.  For example:
SI_NUMDISKS   - The number of disk
SI_DISKNAME_# - Disk name
SI_DISKSIZE_# - Size of disk
Note: There is a problem with the following script. I should examine the existing partitions on the client using fdisk, but aiuser does not have permission to do this. I can get over it by modify the solaris boot environment (see future blog entry).


# cat lab_manifest.sh
#!/bin/ksh93
SCRIPT_SUCCESS=0
SCRIPT_FAILURE=1
function handler
{
    exit $SCRIPT_FAILURE
}
trap handler ERR

# Load a default manifest (must be a local file)
/usr/bin/aimanifest load /usr/share/auto_install/manifest/default.xml

# This script only works with 1 disk
if [[ $SI_NUMDISKS -gt "1" ]] ; then
    print -u2 "System has too many disks for this script."
    exit $SCRIPT_FAILURE

fi

# System will reboot after installation = true (otherwise false)
/usr/bin/aimanifest set \
    /auto_install/ai_instance@auto_reboot true

# Make Disk 1 the target disk
/usr/bin/aimanifest add \
    /auto_install/ai_instance/target/disk/disk_name@name $SI_DISKNAME_1

# Check disk being used is bigger enough (> 250GB)
if [[ $SI_DISKSIZE_1 -gt "256000" ]] ; then
    typeset -i PARTN_SIZE=61440

    # First Partitions is Windows so preserve all data on it
    /usr/bin/aimanifest add \
        /auto_install/ai_instance/target/disk[disk_name@name=\"$SI_DISKNAME_1\"]/partition@name 1
    /usr/bin/aimanifest set \
        /auto_install/ai_instance/target/disk/disk_name@name_type ctd
    /usr/bin/aimanifest set \
        /auto_install/ai_instance/target/disk/partition[@name=1]@action preserve

    # Create second partitions and install Solaris (PARTN_SIZE=64GB)
    /usr/bin/aimanifest add \
        /auto_install/ai_instance/target/disk[disk_name@name=\"$SI_DISKNAME_1\"]/partition@name 2
    /usr/bin/aimanifest add \
        /auto_install/ai_instance/target/disk/partition[@name=2]/size@val \
        ${PARTN_SIZE}mb
    /usr/bin/aimanifest set \
        /auto_install/ai_instance/target/disk/partition[@name=2]@action create

else
    print -u2 "System has too smaller disk. $SI_DISKSIZE_1"
    exit $SCRIPT_FAILURE
fi

# Remove facet which are in default file and only keep locale.* (facet[1])
# Unable to add a facet so added a workround
# Get list of current facets and delete unwanted ones
facets=$(/usr/bin/aimanifest get software/destination/image/facet)
count=1
for i in $facets
do
        if [ $count -gt 3 ]; then
                /usr/bin/aimanifest delete software/destination/image/facet[3]
        fi
        count=$((count + 1))
done

# Replace facet[2] with locale.en and facet[3] with locale.en_G
/usr/bin/aimanifest set \
        software/destination/image/facet[2] facet.locale.en
/usr/bin/aimanifest set \
        software/destination/image/facet[2]@set true
/usr/bin/aimanifest set \
        software/destination/image/facet[3] facet.locale.en_GB
/usr/bin/aimanifest set \
        software/destination/image/facet[3]@set true

# Set the locatiopn of our internal Solaris publisher
/usr/bin/aimanifest set \
        software/source/publisher/origin@name http://193.xx.xx.xx
/usr/bin/aimanifest add \
      software[@type=IPS]/source[publisher@name=solaris]/publisher@name dcsnt  

# Add addition publisher
/usr/bin/aimanifest add \
        publisher[@name=dcsnt]/origin@name \
        http://193.xx.xx.xx:10091

# Remove default software (pkg:/group/system/solaris-large-server)
/usr/bin/aimanifest delete \
    software/software_data/name

# install our software
/usr/bin/aimanifest add \
    software/software_data[@action='install']/name pkg:/entire@0.5.11-0.175
/usr/bin/aimanifest add \
    software/software_data[@action='install']/name pkg:/group/system/solaris-desktop
/usr/bin/aimanifest add \
    software/software_data[@action='install']/name pkg:/service/network/ntp
/usr/bin/aimanifest add \
    software/software_data[@action='install']/name pkg:/system/dcsntinstall
/usr/bin/aimanifest add \
    software/software_data[@action='install']/name pkg:/system/dcsntXinstall
/usr/bin/aimanifest add \
    software/software_data[@action='install']/name pkg:/library/desktop/aoo340
/usr/bin/aimanifest add \
    software/software_data[@action='install']/name pkg:/system/dcsntExtraSW
/usr/bin/aimanifest add \
    software/software_data[@action='install']/name pkg:/system/dcsntupdate

# uninstall our software
/usr/bin/aimanifest add \
    software[@type="IPS"]/software_data@action uninstall
/usr/bin/aimanifest add \
    software/software_data[@action='uninstall']/name pkg:/system/management/ocm
/usr/bin/aimanifest add \
    software/software_data[@action='uninstall']/name  pkg:/system/management/visual-panels/panel-sysmon
/usr/bin/aimanifest add \
    software/software_data[@action='uninstall']/name pkg:/system/management/visual-panels/panel-sysmon/locale

exit $SCRIPT_SUCCESS

Test the Derived Manifest Script in an Install Environment

  • Boot an AI image on that client system in "Text Installer and command line" mode
  • Select Shell from the installer initial menu
  • Copy your script to the client (ftp, ssh)
  • as root
# chmod a+x  /var/tmp/lab_manifest.sh
# auto-install -m /var/tmp/lab_manifest.sh -i

15:50:52    Install Log: /system/volatile/install_log
15:50:52    Using Derived Script: /var/tmp/lab_manifest.sh
15:50:52    Starting installation.
15:50:52    Deriving manifest from: /var/tmp/lab_manifest.sh
15:50:52    Derived /var/tmp/lab_manifest.sh stored
15:50:52    Registering Derived Manifest Module Checkpoint
15:50:52    0% Preparing for Installation
15:50:52    Derived Manifest Module: Creating/modifying manifest at "/system/volatile/manifest.xml"
...
15:51:08    Derived Manifest Module: XML validation completed successfully
15:51:09    84% derived-manifest completed.
15:51:09    100% manifest-parser completed.
15:51:09    100% None
15:51:09    DM set manifest to: /system/volatile/manifest.xml
15:51:09    0% Preparing for Installation
15:51:09    1% Preparing for Installation
15:51:09    2% Preparing for Installation
15:51:09    3% Preparing for Installation
15:51:12    64% target-discovery completed.
15:51:12    Creating partition 2 on disk c1t0d0 will destroy existing data.
15:51:12    Selected Disk(s) : c1t0d0
15:51:12    Existing zpool 'rpool' will be destroyed.
15:51:12    82% target-selection completed.
15:51:12    94% ai-configuration completed.
15:51:12    100% var-share-dataset completed.
15:51:12    100% None
15:51:12    Automated Installation paused at checkpoint: target-instantiation
15:51:12    Automated Installation succeeded.
15:51:12    You may wish to reboot the system at this time.

Check out if the manifest it has created looks correct!
 

# cat /system/volatile/manifest.xml
<!DOCTYPE auto_install SYSTEM "file:///usr/share/install/ai.dtd.1">
<auto_install>
  <ai_instance name="default" auto_reboot="true">
    <target>
      <disk>
        <disk_name name="c1t0d0" name_type="ctd"/>
        <partition name="1" action="preserve"/>
        <partition name="2" action="create">
          <size val="61440mb"/>
        </partition>
      </disk>
      <logical>
        <zpool name="rpool" is_root="true">
          <filesystem name="export" mountpoint="/export"/>
          <filesystem name="export/home"/>
          <be name="solaris"/>
        </zpool>
      </logical>
    </target>
    <software type="IPS">
      <destination>
        <image>
          <!-- Specify locales to install -->
          <facet set="false">facet.locale.*</facet>
          <facet set="true">facet.locale.en</facet>
          <facet set="true">facet.locale.en_GB</facet>
        </image>
      </destination>
      <source>
        <publisher name="solaris">
          <origin name="http://193.xx.xx.xx"/>
        </publisher>
        <publisher name="dcsnt">
          <origin name="http://193.xx.xx.xx:10091"/>
        </publisher>
      </source>
      <software_data action="install">
        <name>pkg:/entire@0.5.11-0.175</name>
        <name>pkg:/group/system/solaris-desktop</name>
        <name>pkg:/service/network/ntp</name>
        <name>pkg:/system/dcsntinstall</name>
        <name>pkg:/system/dcsntXinstall</name>
        <name>pkg:/library/desktop/aoo340</name>
        <name>pkg:/system/dcsntExtraSW</name>
        <name>pkg:/system/dcsntupdate</name>
      </software_data>
      <software_data action="uninstall">
        <name>pkg:/system/management/ocm</name>
        <name>pkg:/system/management/visual-panels/panel-sysmon</name>
        <name>pkg:/system/management/visual-panels/panel-sysmon/locale</name>
      </software_data>
    </software>
  </ai_instance>
</auto_install>

Quick Setup Guide for AI

# svcadm enable /network/dns/multicast
# svcs /network/dns/multicast
STATE          STIME    FMRI
online         13:58:08 svc:/network/dns/multicast:default
# pkg install install/installadm
# installadm create-service
OK to use subdir of /export/auto_install to store image? [y|N]: y
  0% : Creating service from: pkg:/install-image/solaris-auto-install
  0% : Using publisher(s):
  0% :     emulex: http://pkg.emulex.com:8080/
  0% :     solaris: http://pkgs.dcs.bbk.ac.uk/
  5% : Refreshing Publisher(s) 
  9% : Startup Phase 
 15% : Planning Phase 
 61% : Download Phase 
 90% : Actions Phase 
 91% : Finalize Phase
 91% : Creating i386 service: solaris11_2_1_0_2-i386
 91% : Image path: /export/auto_install/solaris11_2_1_0_2-i386
 91% : Setting "solaris" publisher URL in default manifest to:
 91% :  http://pkgs.dcs.bbk.ac.uk/
 91% : DHCP is not being managed by install server.
 91% : SMF Service 'svc:/system/install/server:default' will be enabled
 91% : SMF Service 'svc:/network/tftp/udp6:default' will be enabled
 91% : Creating default-i386 alias
 91% : Setting "solaris" publisher URL in default manifest to:
 91% :  http://pkgs.dcs.bbk.ac.uk/
 91% : DHCP is not being managed by install server.
 91% :  No local DHCP configuration found. This service is the default
 91% :  alias for all PXE clients. If not already in place, the following should
 91% :  be added to the DHCP configuration:
 91% : Boot server IP: 193.61.28.144
 91% : Boot file(s):
 91% :     bios clients (arch 00:00):  default-i386/boot/grub/pxegrub2
 91% :     uefi clients (arch 00:07):  default-i386/boot/grub/grub2netx64.efi
 91% :
 91% : SMF Service 'svc:/system/install/server:default' will be enabled
 91% : SMF Service 'svc:/network/tftp/udp6:default' will be enabled
100% : Created Service: 'solaris11_2_1_0_2-i386'
100% : Refreshing SMF service svc:/network/tftp/udp6:default
100% : Refreshing SMF service svc:/system/install/server:default
100% : Enabling SMF service svc:/system/install/server:default
100% : Enabling SMF service svc:/network/tftp/udp6:default
100% : Service 'solaris11_2_1_0_2-i386' has been added to the mDNS registry
100% : Service 'default-i386' has been added to the mDNS registry

# installadm list
Service Name           Status Arch Type Secure Alias Aliases Clients Profiles Manifests
------------           ------ ---- ---- ------ ----- ------- ------- -------- ---------
default-i386           on     i386 pkg  no     yes   0       0       0        1       
solaris11_2_1_0_2-i386 on     i386 pkg  no     no    1       0       0        1       

# installadm list -m -n solaris11_2_1_0_2-i386
Service Name           Manifest Name Type    Status  Criteria
------------           ------------- ----    ------  --------
solaris11_2_1_0_2-i386 orig_default  derived default none   

# installadm list -m -p
Service Name           Manifest Name Type    Status  Criteria
------------           ------------- ----    ------  --------
default-i386           orig_default  derived default none   
solaris11_2_1_0_2-i386 orig_default  derived default none   
There are no profiles configured for local services.

Create a default profile (see: http://docs.oracle.com/cd/E36784_01/html/E36800/syscfg-3.html)

# sysconfig create-profile -o sc.xml
# installadm create-profile -n solaris11_2_1_0_2-i386 -f sc.xml
# installadm create-manifest -n solaris11_2_1_0_2-i386 -f lab_manifest.sh
# installadm set-criteria -n solaris11_2_1_0_2-i386 -m lab_manifest.sh -c mac="40:26:7A:A4:1A:41-70:71:BC:7C:85:21"

# installadm create-client -e 40:26:7A:A4:1A:41 -n solaris11_2_1_0_2-i386  -b console=graphics
No local DHCP configuration found. If not already configured, the
following should be added to the DHCP configuration:
    Boot server IP      : 193.xx.xx.xx
    Boot file(s)        :
                        :       bios clients (arch 00:00):  40267AA41A41.bios
                        :       uefi clients (arch 00:07):  40267AA41A41.uefi
                        :
Created Client: '40:26:7A:A4:1A:41'

# installadm list -n solaris11_2_1_0_2-i386 -m -c -p
Service Name           Client Address    Arch Secure Custom Args Custom Grub
------------           --------------    ---- ------ ----------- -----------
solaris11_2_1_0_2-i386 40:26:7A:A4:1A:41 i386 no     yes         no        
      
Service Name           Manifest Name    Type    Status  Criteria                                  
------------           -------------    ----    ------  --------                                  
solaris11_2_1_0_2-i386 lab_manifest.sh derived active  mac = 40:26:7A:A4:1A:41 - 70:71:BC:7C:85:21                   
                       orig_default     derived default none                                      
Service Name           Profile Name Criteria
------------           ------------ --------
solaris11_2_1_0_2-i386 sc.xml      none   



1 comment:

Heider said...

You've discussed in older posts about building a standalone AI dvd with modified manifest/sc_profile/etc. Do you know if it's possible to include the derived manifest script on the DVD as opposed to requiring network connection to the install service?