suse

How to use autoyast to install an external package while installing Suse unattended?


Recently I'm learning how to use autoyast to install SUSE unattendly via network with pxe. My target is --

  1. Unattended install Suse12.4 with pxe -- I have made it successfully with autoyast.xml and pxe

  2. The install not only install Suse only, but also need to install some external packages -- eg. rlwrap and puppet client... Follow the steps in https://documentation.suse.com/sles/12-SP4/html/SLES-all/configuration.html#CreateProfile-Software -- in Section 4.9.2 So I made a test with rlwrap package only, here are my steps--

  3. Since my repository was http://192.168.95.77/12.4, so I copied rlwrap-0.43-lp152.3.8.x86_64.rpm to http://192.168.95.77/12.4/suse/x86_64 and make sure it's available from http.

  4. Then I modified my autoyast.xml add this at the file end--

    <add-on>
      <add_on_products config:type="list">
        <listentry>
          <media_url>http://192.168.95.77/12.4/suse/x86_64/rlwrap-0.43-lp152.3.8.x86_64.rpm</media_url>
          <product>rlwrap</product>
          <alias>rlwrap</alias>
          <product_dir></product_dir>
          <priority config:type="integer">99</priority>
          <ask_on_error config:type="boolean">false</ask_on_error>
          <confirm_license config:type="boolean">false</confirm_license>
          <name>eisen-repo-12.4</name>
        </listentry>
      </add_on_products>
    </add-on>
    

Then I tested with a new VM, -- then I found this VM was successfully installed Suse12.4 again, But that rlwrap package was not installed and there's no error message found in installation.


Solution

  • Find the solution -- the init.sh part in the autoyast.xml can do it. I wrote it like this --

      <scripts>
        <init-scripts config:type="list">
          <script>
            <debug config:type="boolean">true</debug>
            <feedback config:type="boolean">false</feedback>
            <filename>init.sh</filename>
            <interpreter>shell</interpreter>
            <location><![CDATA[]]></location>
            <notification>customer initialization</notification>
            <source><![CDATA[
    #!/bin/bash
    touch /tmp/flag
    rpm --import http://192.168.95.77/puppet7/repodata/repomd.xml.key 2>&1 >> /tmp/flag
    zypper addrepo -f http://192.168.95.77/puppet7 eisen-repo-puppet7 2>&1 >> /tmp/flag
    zypper install -y rlwrap 2>&1 >> /tmp/flag
    zypper install -y puppet-agent 2>&1 >> /tmp/flag
            ]]></source>
          </script>
        </init-scripts>
      </scripts>
    

    Then the 3rd party packages are installed successfully.