<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="/stylesheets/rss.css" type="text/css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>HJK Solutions: Unattended Package Installation with Debian and Ubuntu</title>
    <link>http://blog.hjksolutions.com/articles/2007/07/27/unattended-package-installation-with-debian-and-ubuntu</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>We Launch Startups</description>
    <item>
      <title>Unattended Package Installation with Debian and Ubuntu</title>
      <description>&lt;p&gt;&lt;a href="http://en.wikipedia.org/wiki/Advanced_Packaging_Tool"&gt;Apt&lt;/a&gt; is a wonderful tool, but it does have its quirks.  One of those is that it likes to ask you interactive questions during package installation.  This makes total sense when a human is doing &lt;code&gt;apt-get install foobar&lt;/code&gt;, but it causes all sorts of consternation when you want to automatically install packages. (You do this all the time with &lt;a href="http://puppet.reductivelabs.com"&gt;Puppet&lt;/a&gt;, which I&amp;#8217;ll talk more about at the end of this post.)&lt;/p&gt;


	&lt;p&gt;The answer to this problem is to pre-seed &lt;a href="http://www.fifi.org/doc/debconf-doc/tutorial.html"&gt;debconf&lt;/a&gt; with the correct answers to it&amp;#8217;s questions.  To do this, first you need to install the package by hand:&lt;/p&gt;


&lt;pre&gt;
    &lt;code&gt;
$ apt-get install libnss-ldap
    &lt;/code&gt;
&lt;/pre&gt;

	&lt;p&gt;You&amp;#8217;ll need to provide answers to the questions it asks, which we&amp;#8217;re going to re-use later as the basis for our seed file.  Next, make sure you have &lt;code&gt;debconf-utils&lt;/code&gt; installed, and grab the answers to your questions:&lt;/p&gt;


&lt;pre&gt;
    &lt;code&gt;
$ apt-get install debconf-utils # Only if you need it
$ debconf-get-selections | grep libnss-ldap
libnss-ldap     libnss-ldap/rootbindpw  password
libnss-ldap     libnss-ldap/bindpw      password
libnss-ldap     libnss-ldap/dblogin     boolean false
# Automatically update libnss-ldap's configuration file?
libnss-ldap     libnss-ldap/override    boolean false
libnss-ldap     shared/ldapns/base-dn   string   dc=example,dc=com
libnss-ldap     libnss-ldap/rootbinddn  string   cn=admin,dc=example,dc=com
libnss-ldap     shared/ldapns/ldap_version      select   3
libnss-ldap     libnss-ldap/binddn      string   cn=proxyuser,dc=example,dc=net
libnss-ldap     shared/ldapns/ldap-server       string   ldapi:///
libnss-ldap     libnss-ldap/nsswitch    note
libnss-ldap     libnss-ldap/confperm    boolean false
libnss-ldap     libnss-ldap/dbrootlogin boolean true
    &lt;/code&gt;
&lt;/pre&gt;

	&lt;p&gt;Take the output of that and stick it in a file, say &lt;code&gt;libnss-ldap.seed&lt;/code&gt;.  You can now use that file to pre-seed a new system with those answers using debconf-set-selections:&lt;/p&gt;


&lt;pre&gt;
    &lt;code&gt;
$ debconf-get-selections | grep libnss-ldap &amp;gt; /tmp/libnss-ldap.seed
$ debconf-set-selections /tmp/libnss-ldap.seed
    &lt;/code&gt;
&lt;/pre&gt;

	&lt;p&gt;Or use ssh to pre-seed a new box:&lt;/p&gt;


&lt;pre&gt;
    &lt;code&gt;
$ cat /tmp/libnss-ldap.seed | ssh somehost debconf-set-selections
    &lt;/code&gt;
&lt;/pre&gt;

	&lt;p&gt;If you are using &lt;a href="http://puppet.reductivelabs.com"&gt;Puppet&lt;/a&gt; (and if you&amp;#8217;re not, you should be) to manage your systems, you can use a recipe like this to automatically install packages that require interaction:&lt;/p&gt;


&lt;pre&gt;
    &lt;code&gt;
define seed_package($ensure = latest) {
  $seedpath = "/var/cache/local/preseeding" 
  file { "$seedpath/$name.seed":
    source =&amp;gt; "puppet://$puppet_server/seeds/$lsbdistcodename/$name.seed",
    mode =&amp;gt; 0600,
    owner =&amp;gt; root,
    group =&amp;gt; root
  }
  package { $name:
    ensure =&amp;gt; $ensure,
    responsefile =&amp;gt; "$seedpath/$name.seed",
    require =&amp;gt; File["$seedpath/$name.seed"],
  }
}

class foobar {
  seed_package { "libnss-ldap":
    ensure =&amp;gt; latest
  }
}
    &lt;/code&gt;
&lt;/pre&gt;

	&lt;p&gt;Some other resources on ways to use pre-seeding to great effect:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;&lt;a href="http://www.debian-administration.org/articles/394"&gt;Automating new Debian installations with preseeding at Debian Administration&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href="http://wiki.debian.org/DebianInstaller/Preseed"&gt;Preseed entry at the Debian Wiki&lt;/a&gt;&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;Happy unattended package installation! :)&lt;/p&gt;</description>
      <pubDate>Fri, 27 Jul 2007 10:05:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:04ea761d-3f21-4868-b91d-6fc83dedbe47</guid>
      <author>Adam Jacob</author>
      <link>http://blog.hjksolutions.com/articles/2007/07/27/unattended-package-installation-with-debian-and-ubuntu</link>
      <category>solutions</category>
      <category>ubuntu</category>
      <category>debian</category>
      <category>puppet</category>
      <trackback:ping>http://blog.hjksolutions.com/articles/trackback/6</trackback:ping>
    </item>
    <item>
      <title>"Unattended Package Installation with Debian and Ubuntu" by Ian J Cottee</title>
      <description>&lt;p&gt;Excellent &amp;#8211; very useful info. Thanks!&lt;/p&gt;</description>
      <pubDate>Sun, 28 Oct 2007 11:07:26 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:7ab61246-992c-483a-a2e7-74318e62854f</guid>
      <link>http://blog.hjksolutions.com/articles/2007/07/27/unattended-package-installation-with-debian-and-ubuntu#comment-1186</link>
    </item>
  </channel>
</rss>
