5

I have built an automatic installation system for building nodes from bare metal, it produces a pretty basic install, then installs puppet and contacts the puppetmaster for the rest of the configuration. What I would like to be able to do is inject a question into the preseed such that I could ask "what is the role of this server?" which in turn would just write the value to a temporary file, that facter would parse and include in the puppet catalog run.

So Basically, ask a question during install, provide a list of available answers and write the response to a file.

is that do-able?

1 Answer 1

3

You can use the d-i preseed/late_command section of the preseed file to run a script which uses the debconf to ask a custom question.

Example script:

#! /bin/sh

# This is a debconf-compatible script
. /usr/share/debconf/confmodule

# Create the template file
cat > /tmp/myquestion.template <<'!EOF!'
Template: my-question/ask
Type: select
Choices: First, Second, Third
Description: Custom question
 Template for querying a basic text.

Template: my-question/title
Type: text
Description: My question text
!EOF!

# Load your template
debconf-loadtemplate my-question /tmp/myquestion.template

# Set title for your custom dialog box
db_settitle my-question/title

# Ask it!
db_input critical my-question/ask
db_go

# Get the answer
db_get my-question/ask

# Save it to a file
echo "$RET" > /tmp/answer.value

After the script runs, you will find the answer in the /tmp/answer.value file.

More info: https://help.ubuntu.com/community/InstallCDCustomization/AccessDebconfFromYourScript

1
  • 1
    You should use db_x_loadtemplatefile /tmp/myquestion.template my-question instead of debconf-loadtemplate my-question /tmp/myquestion.template. Dec 18, 2014 at 15:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .