4.17.  Ask the user for values during installation

This feature is only available since SUSE Linux 10.1 and SLES10.

You have the option to let the user decide the values of specific parts of the profile during the installation. If you use that feature, a popup will come up during the installation and will ask the user to enter a specific part of the profile. So if you want a full auto installation but you want the user to set the password of the local account, you can do this via the ask directive in the profile.

The following elements must be between the <ask-list config:type="list"><ask> ... </ask></ask-list> tags in the <general> section.

Table 4.16. XML representation

ElementDescriptionComment
questionThe question you want to ask the user.
<question>Enter the LDAP server</question>
The default value is the path to the element (the path often looks strange, so I recommend to enter a question)
defaultyou can set a pre-selection for the user. A textentry will be filled out with this value, a checkbox will be "true" or "false" and a selection will have this default "value" pre-selected.
<default>dc=suse,dc=de</default>
optional
helpAn optional helptext that is shown on the left side of the question.
<help>Enter the LDAP server address.</help>
optional
titleAn optional title that is shown above the questions.
<title>LDAP server</title>
optional
typethe type of the element you want to change. Possible values are "symbol","boolean","string" and "integer". The filesystem in the partition section is a symbol, while the "encrypted" element in the user configuration is a boolean. You can see the type of that element if you look in your profile at the config:type="...." attribute.
<type>symbol</type>
optional. The defaul is string. If type is "symbol" you must provide the selection element too (see below)
passwordif this boolean is set to "true", a password dialog pops up instead of a simple text entry. Setting this to "true" makes only sense if "type" is string.
<password config:type="boolean">true</password>
optional. The default is "false"
path (deprecated since openSUSE 11.0 - use pathlist)The path to the element in the profile. It's a comma seperated list of elements that describes the path to the element you want to change. For example, the ldap server element can be found in the profile in the <ldap><ldap_server> section. So if you want to change that value, you have to set the path to "ldap,ldap_server". If you want to change the password of the first user in the profile, you have to set the path to "users,0,user_password". The "0" indicates the first user in the <users config:type="list"> list of users in the profile.
<path>networking,dns,hostname</path>
this information is optional but you should at least provie path or file
pathlist (available since openSUSE 11.0 and replaces path)a list of path elements (see above)
<pathlist config:type="list"><path>networking,dns,hostname</path><path>...</path>
this information is optional but you should at least provie path or file
file (available since SLES10 SP1 and SL 10.2)you can store the answer to a question in a file, to use it in one of your scripts later.
<file>/tmp/answer_hostname</file>
this information is optional but you should at least provie path or file
passwordif this boolean is set to "true", a password dialog pops up instead of a simple text entry. Setting this to "true" makes only sense if "type" is string.
<password config:type="boolean">true</password>
optional. The default is "false"
stagestage configures the installation stage where the question pops up. You can set this value to "cont" or "initial". "initial" means the popup comes up very early in the installation, short after the pre-script has run. "cont" means, that the dialog with the question comes after the first reboot, when the system boots for the very first time. Questions you answer during the "inital" stage, will write their answer into the profile on the harddisk. You should know that if you enter cleartext passwords during "initial". Of course it does not make sense to ask for a filesystem to use in the "cont" phase. The harddisk is already partitioned at that stage and the question will have no effect.
<stage>cont</stage>
optional. The default is "initial"
selectionthe selection element contains a list of <entry> elements. Each entry represents a possible option for the user to choose. So the user can't enter a value in a textfield, but he can choose from a list of values.
<selection config:type="list">
  <entry>
    <value>
        reiser
    </value>
    <label>
        Reiser Filesystem
    </label>
  </entry>
  <entry>
    <value>
        ext3
    </value>
    <label>
        Extended3 Filesystem
    </label>
  </entry>
</selection>
optional for type=string, not possible for type=boolean and a must have for type=symbol
dialog (available since SL 10.3 and SLES10 SP2)Since OpenSUSE 10.3 you can have more than one question per dialog. To make that possible you have to specifiy the dialog-id with an integer. All questions with the same dialog-id are on the same dialog. The dialogs are sorted by the id too.
<dialog config:type="integer">3</dialog>
optional
element (available since SL 10.3 and SLES10 SP2)Since OpenSUSE 10.3 you can have more than one question per dialog. To make that possible you have to specifiy the element-id with an integer. The questions on a dialog are sorted by the id.
<element config:type="integer">1</element>
optional (see dialog>
frametitle (available since SL 10.3 and SLES10 SP2)Since OpenSUSE 10.3 you can have more than one question per dialog. Each question on a dialog has a frame that can have a frametitle. A small caption for each question if you want so.
<frametitle>User data</frametitle>
optional (default is no frametitle)
script (available since SL 10.3 not in SLES10 SP1)with 10.3 you can run scripts after a question has been answered (see the table below for detailed instructions about scripts)
<script>...</script>
optional (default is no script)


The following elements must be between the <ask-list config:type="list"><ask><script>...</script>...</ask></ask-list> tags in the <general> section. It's available since 10.3 (not SLES10 SP1).

Table 4.17. XML representation

ElementDescriptionComment
filenamethe filename of the script
<filename>my_ask_script.sh</filename>
default is ask_script.sh
sourcethe source code of the script. Together with "rerun_on_error" on you check the value that was entered for sanity (since 11.0 only). Your script can create a file "/tmp/next_dialog" with a dialog id in it. That's the next dialog autoyast will raise then. A value of -1 terminates the ask sequence. If that file is not created, autoyast will run the dialogs in a normal order (since 11.0 only)
<source>...</source>
this value is required. Otherwise nothing would be executed
environmenta boolean that passes the "value" of the answer to the question as an environment variable to the script. The variable is named "VAL".
<environment config:type="boolean">true</environment>
optional (default is "false").
feedbacka boolean that turns on feedback for the script execution. That means that STDOUT will be shown in a popup box that must be confirmed after the script execution.
<feedback config:type="boolean">true</feedback>
optional (default is "false").
debuga boolean that turns on debugging for the script execution
<debug config:type="boolean">true</debug>
optional (default is "false"). This value needs feedback to be turned on too.
rerun_on_error (available since openSUSE 11.0)a boolean that keeps the dialog open until the script has an exit code of 0 (zero). So you can parse and check the answers the user gave in the script and popup an error with the "feedback" option.
<rerun_on_error config:type="boolean">true</rerun_on_error>
optional (default is "false"). This value should be used together with the feedback option.


Below you can see an example of the usage of the "ask" feature.

<general>
  <ask-list config:type="list">
      <ask>
          <!-- deprecated since openSUSE 11.0; use pathlist instead
          <path>ldap,ldap_server</path>
          -->
          <pathlist config:type="list">
              <path>ldap,ldap_server</path>
          </pathlist>
          <stage>cont</stage>
          <help>choose your server depending on your department</help>
          <selection config:type="list">
              <entry>
                      <value>ldap1.mydom.de</value>
                      <label>LDAP for development</label>
              </entry>
              <entry>
                      <value>ldap2.mydom.de</value>
                      <label>LDAP for sales</label>
              </entry>
          </selection>
          <default>ldap2.mydom.de</default>
      </ask>
      <ask>
          <!-- deprecated since openSUSE 11.0; use pathlist instead
          <path>networking,dns,hostname</path>
          -->
          <pathlist config:type="list">
              <path>networking,dns,hostname</path>
          </pathlist>
          <question>Enter Hostname</question>
          <stage>initial</stage>
          <default>enter your hostname here</default>
      </ask>
      <ask>
          <!-- deprecated since openSUSE 11.0; use pathlist instead
          <path>partitioning,0,partitions,0,filesystem</path>
          -->
          <pathlist config:type="list">
              <path>partitioning,0,partitions,0,filesystem</path>
          </pathlist>
          <question>Filesystem</question>
          <type>symbol</type>
          <selection config:type="list">
              <entry>
                      <value config:type="symbol">reiser</value>
                      <label>default Filesystem (recommended)</label>
              </entry>
              <entry>
                      <value config:type="symbol">ext3</value>
                      <label>Fallback Filesystem</label>
              </entry>
          </selection>

      </ask>
  </ask-list>
  ...
</general>

The following example is a nice way to choose between autoyast profiles. Autoyast will read the "modified.xml" file again after the ask-dialogs are done. So we can fetch a complete new profile.

      <ask>
        <selection config:type="list">
            <entry>
                    <value>part1.xml</value>
                    <label>Simple partitioning</label>
            </entry>
            <entry>
                    <value>part2.xml</value>
                    <label>encrypted /tmp</label>
            </entry>
            <entry>
                    <value>part3.xml</value>
                    <label>LVM</label>
            </entry>
        </selection>
        <title>XML Profile</title>
        <question>Choose a profile</question>
        <stage>initial</stage>
        <default>part1.xml</default>
        <script>
            <filename>fetch.sh</filename>
            <environment config:type="boolean">true</environment>
            <source><![CDATA[
wget http://10.10.0.162/$VAL -O /tmp/profile/modified.xml 2>/dev/null
]]>
            </source>
            <debug config:type="boolean">false</debug>
            <feedback config:type="boolean">false</feedback>
        </script>
      </ask>

Since openSUSE 11.0 you can verify the answer of a question with a script like this:

     <ask>
          <script>
            <filename>my.sh</filename>
            <rerun_on_error config:type="boolean">true</rerun_on_error>
            <environment config:type="boolean">true</environment>
            <source><![CDATA[
if [ "$VAL" = "myhost" ]; then
    echo "Illegal Hostname!";
    exit 1;
fi
exit 0
]]>
            </source>
            <debug config:type="boolean">false</debug>
            <feedback config:type="boolean">true</feedback>
          </script>
          <dialog config:type="integer">0</dialog>
          <element config:type="integer">0</element>
          <!-- deprecated since openSUSE 11.0; use pathlist instead
          <path>networking,dns,hostname</path>
          -->
          <pathlist config:type="list">
              <path>networking,dns,hostname</path>
          </pathlist>
          <question>Enter Hostname</question>
          <default>enter your hostname here</default>
      </ask>