summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorintrigeri <intrigeri@boum.org>2017-05-30 09:41:03 +0000
committerintrigeri <intrigeri@boum.org>2017-05-30 09:41:03 +0000
commit6e54c32751efe11764b138a099616a71c627baa9 (patch)
tree1a1d298f9b982f778dbc3bdc8e54d19dcb745086
parent6739923a0f75ffc82d0822eb15636cb244b8e31f (diff)
parent9a4adac94a72d8bd8c3d5b4657adac15f43ecd30 (diff)
Merge remote-tracking branch 'lelutin-gitlab/package' (Closes: #5)
-rw-r--r--README.md44
-rw-r--r--manifests/package.pp43
-rw-r--r--manifests/preseeded_package.pp26
3 files changed, 84 insertions, 29 deletions
diff --git a/README.md b/README.md
index 32c86db..13990cc 100644
--- a/README.md
+++ b/README.md
@@ -19,7 +19,7 @@
* [Defines](#defines)
* [apt::apt_conf](#apt-apt_conf)
* [apt::preferences_snippet](#apt-preferences_snippet)
- * [apt::preseeded_package](#apt-preseeded_package)
+ * [apt::package](#apt-package)
* [apt::sources_list](#apt-sources_list)
* [apt::key](#apt-key)
* [`apt::key::plain`](#apt-key-plain)
@@ -156,6 +156,10 @@ Ubuntu support is lagging behind but not absent either.
port => '666';
}
+ * <a name="apt-preseeded_package"></a>the `apt::preseeded_package` defined
+ type was renamed `apt::package`. the previous name is now deprecated and
+ will be removed in the future.
+
# Requirements<a name="requirements"></a>
@@ -500,23 +504,45 @@ From apt_preferences(5):
characters - otherwise they will be silently ignored.
-## apt::preseeded_package<a name="apt-preseeded_package"></a>
+## apt::package<a name="apt-package"></a>
This simplifies installation of packages for which you wish to preseed the
-answers to debconf. For example, if you wish to provide a preseed file for the
-locales package, you would place the `locales.seed` file in
+answers to debconf or pin to a certain version.
+
+To use preseeding you need to set the `use_seed` parameter to true. For
+example, if you wish to provide a preseed template for the locales package, you
+would place the `locales.seed` file in
`site_apt/templates/${::lsbdistcodename}/locales.seeds` and then include the
following in your manifest:
- apt::preseeded_package { locales: }
+ apt::package { 'locales':
+ use_seed => true,
+ }
+
+You can change what template is used by setting `seedfile_template` to a
+template path of your choosing (same as you would pass to the template()
+function).
+
+You can also specify the content of the seed via the `seedfile_content`
+parameter instead of using a template, for example:
+
+ apt::package { 'apticron':
+ use_seed => true,
+ seedfile_content => 'apticron apticron/notification string root@example.com',
+ }
-You can also specify the content of the seed via the content parameter,
-for example:
+To pin a package to a certain release or version, you need to set the `pin`
+parameter to the restriction that you want (this value corresponds to the
+'Pin:' line in preferences files). For example this would pin the package
+ganeti to the jessie release:
- apt::preseeded_package { 'apticron':
- content => 'apticron apticron/notification string root@example.com',
+ apt::package { 'ganeti':
+ pin => 'release o=Debian Backports,a=jessie',
}
+Also, if you want to set a priority number to a package pin, you can set
+`pin_priority` to an integer value. The default value of this parameter is
+1000, which will install but not downgrade a package.
## apt::sources_list<a name="apt-sources_list"></a>
diff --git a/manifests/package.pp b/manifests/package.pp
new file mode 100644
index 0000000..e83ac68
--- /dev/null
+++ b/manifests/package.pp
@@ -0,0 +1,43 @@
+# Install a package with a preseed file to automatically answer some questions.
+define apt::package (
+ $ensure = 'present',
+ $use_seed = false,
+ $seedfile_template = "site_apt/${::debian_codename}/${name}.seeds",
+ $seedfile_content = '',
+ $pin = '',
+ $pin_priority = 1000
+) {
+
+ package { $name:
+ ensure => $ensure,
+ responsefile => $seedfile,
+ }
+
+ if $use_seed {
+ $seedfile = "/var/cache/local/preseeding/${name}.seeds"
+ $real_seedfile_content = $seedfile_content ? {
+ '' => template ( $seedfile_template ),
+ default => $seedfile_content,
+ }
+
+ file { $seedfile:
+ content => $real_seedfile_content,
+ mode => '0600',
+ owner => 'root',
+ group => 0,
+ }
+
+ File[$seedfile] -> Package[$name]
+ }
+
+ if $pin {
+ apt::preferences_snippet { $name:
+ ensure => $ensure,
+ priority => $pin_priority,
+ pin => $pin,
+ }
+
+ Apt::Preferences_snippet[$name] -> Package[$name]
+ }
+
+}
diff --git a/manifests/preseeded_package.pp b/manifests/preseeded_package.pp
index 29a981e..e6fcab1 100644
--- a/manifests/preseeded_package.pp
+++ b/manifests/preseeded_package.pp
@@ -1,26 +1,12 @@
-# Install a package with a preseed file to automatically answer some questions.
-
+# This is a wrapper that will be removed after a while
define apt::preseeded_package (
$ensure = 'present',
$content = '',
) {
-
- $seedfile = "/var/cache/local/preseeding/${name}.seeds"
- $real_content = $content ? {
- '' => template ( "site_apt/${::debian_codename}/${name}.seeds" ),
- default => $content,
- }
-
- file { $seedfile:
- content => $real_content,
- mode => '0600',
- owner => 'root',
- group => 0,
- }
-
- package { $name:
- ensure => $ensure,
- responsefile => $seedfile,
- require => File[$seedfile],
+ warning('apt::preseeded_package is deprecated! you should now use apt::package with parameter use_seed set to true instead.')
+ apt::package { $name:
+ ensure => $ensure,
+ use_seed => true,
+ seedfile_content => $content,
}
}