Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: modules/docker/manifests/init.pp

Issue 29370801: Noissue - New module for installing docker on debian (Closed)
Patch Set: Setting the defaults in a more beautiful place Created Jan. 6, 2017, 3:07 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: modules/docker/manifests/init.pp
===================================================================
new file mode 100644
--- /dev/null
+++ b/modules/docker/manifests/init.pp
@@ -0,0 +1,73 @@
+# == Class: docker
+#
+# Install docker (https://www.docker.com/)
+#
+# == Parameters:
+#
+# [*source*]
+# Overwrite the default apt::source used (given Class['apt'] is defined).
+#
+# [*package*]
+# Overwrite the default package options, to fine-tune the target version (i.e.
+# ensure => 'latest') or remove docker (ensure => 'absent' or 'purged')
+#
+# === Examples:
+#
+# class {'docker':
+# package => {
+# ensure => 'latest',
+# },
+# source => {
+# location => 'https://apt.dockerproject.org/repo',
+# release => downcase("$::osfamily-$::lsbdistcodename"),
+# include_src => false,
+# key => '58118E89F3A912897C070ADBF76221572C52609D',
+# key_server => 'hkp://ha.pool.sks-keyservers.net:80',
+# }
+# }
+#
+class docker(
+ $source = hiera('docker::source', {}),
+ $package = hiera('docker::package', {}),
+) {
+
+ include stdlib
+
+ ensure_resource('package', $title, merge({
+ name => 'docker-engine',
+ ensure => 'latest',
+ provider => 'apt',
+ }, $package))
+
+ # Used as default $ensure parameter for most resources below
+ $ensure = getparam(Package[$title], 'ensure') ? {
+ /^(absent|purged|held)$/ => 'absent',
+ default => 'present',
+ }
+
+ # Using ensure_*state functions
+ if ensure_state($ensure) {
+
+ service {'docker':
+ ensure => running,
+ require => Package['docker-engine'],
+ }
+
+ }
+
+ # The only package provider recognized implicitly
+ if getparam(Package[$title], 'provider') == 'apt' {
+
+ ensure_resource('apt::source', $title, merge({
+ before => Package['docker-engine'],
+ location => 'https://apt.dockerproject.org/repo',
+ release => downcase("$::osfamily-$::lsbdistcodename"),
+ include_src => false,
+ key => '58118E89F3A912897C070ADBF76221572C52609D',
+ key_server => 'hkp://ha.pool.sks-keyservers.net:80',
+ }, $source))
+
+ Apt::Source[$title] -> Package[$title]
+ }
+}
+
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld