Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: refactor package management #102

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
; This file is for unifying the coding style for different editors and IDEs.
; Plugins are available for notepad++, emacs, vim, gedit,
; textmate, visual studio, and more.
;
; See http://editorconfig.org for details.

root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
98 changes: 0 additions & 98 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,73 +46,6 @@ class { 'docker':
}
```

To configure package sources independently and disable automatically including sources, add the following code to the manifest file:

```puppet
class { 'docker':
use_upstream_package_source => false,
}
```

The latest Docker [repositories](https://docs.docker.com/engine/installation/linux/docker-ce/debian/#set-up-the-repository) are now the default repositories for version 17.06 and above. If you are using a version prior to this, the old repositories will still be configured based on the version number passed into the module.

The following example will ensure the modules configures the latest repositories

```puppet
class { 'docker':
version => '17.09.0~ce-0~debian',
}
```

Using a version prior to 17.06 will configure and install from the old repositories

```puppet
class { 'docker':
version => '1.12.0-0~wheezy',
}
```

Docker provides a enterprise addition of the [Docker Engine](https://www.docker.com/enterprise-edition), called Docker EE. To install Docker EE on Debian systems, add the following code to the manifest file:

```puppet
class { 'docker':
docker_ee => true,
docker_ee_source_location => 'https://<docker_ee_repo_url',
docker_ee_key_source => 'https://<docker_ee_key_source_url',
docker_ee_key_id => '<key id>',
}
```

To install install Docker EE on RHEL/CentOS:

```puppet
class { 'docker':
docker_ee => true,
docker_ee_source_location => 'https://<docker_ee_repo_url',
docker_ee_key_source => 'https://<docker_ee_key_source_url',
}
```


For Red Hat Enterprise Linux (RHEL) based distributions, including Fedora, the docker module uses the upstream repositories. To continue using the legacy distribution packages in the CentOS Extras repo, add the following code to the manifest file:

```puppet
class { 'docker':
use_upstream_package_source => false,
service_overrides_template => false,
docker_ce_package_name => 'docker',
}
```

To use the CE packages

```puppet
class { 'docker':
use_upstream_package_source => false,
package_ce_name => 'docker-ce',
}
```

By default, the Docker daemon binds to a unix socket at `/var/run/docker.sock`. To change this parameter and to update the binding parameter to a tcp socket, add the following code to the manifest file:

```puppet
Expand Down Expand Up @@ -832,37 +765,6 @@ Valid values are `true`, `false`.

Defaults to `false`.

#### `use_upstream_package_source`

Specifies whether to use the upstream package source.

Valid values are `true`, `false`.

When you run your own package mirror, set the value to `false`.

#### `pin_upstream_package_source`

Specifies whether to use the pin upstream package source. This option relates to apt-based distributions.

Valid values are `true`, `false`.

Defaults to `true`.

Set to `false` to remove pinning on the upstream package repository. See also `apt_source_pin_level`.

#### `apt_source_pin_level`

The level to pin your source package repository to. This relates to an apt-based system (such as Debian, Ubuntu, etc). Include $use_upstream_package_source and set the value to `true`.

To disable pinning, set the value to `false`.

Defaults to `10`.

#### `package_source_location`

Specifies the location of the package source.

For Debian, the value defaults to `http://get.docker.com/ubuntu`.

#### `service_state`

Expand Down
1 change: 1 addition & 0 deletions data/common.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docker::docker_daemon_command: 'docker daemon'
10 changes: 10 additions & 0 deletions data/os/Debian.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
docker::package_repository:
'docker_repo':
location: "https://download.docker.com/linux/%{facts.os.name}"
release: "${facts.os.distro.codename}"
repos: 'stable'
key:
source: "https://download.docker.com/linux/%{facts.os.name"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs a closing brace

include:
deb: true
src: false
4 changes: 4 additions & 0 deletions data/os/Debian/Trusty.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
docker::prerequired_packages:
- 'linux-image-extra-virtual'
- "linux-image-extra-%{facts.os.distro.id}"

4 changes: 4 additions & 0 deletions data/os/Debian/Ubuntu.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
docker::prerequired_packages:
- 'cgroup-lite'
- 'apparmor'
11 changes: 11 additions & 0 deletions data/os/RedHat.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
docker::daemon_command: 'dockerd'
docker::package_repository:
'docker_repo':
ensure: 'present'
assumeyes: true
enabled: true
baseurl: 'https://download.docker.com/linux/centos/7/x86_64/stable'
gpgkey: 'https://download.docker.com/linux/centos/gpg'
repo_gpgcheck: true
sslverify: true
12 changes: 12 additions & 0 deletions hiera.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
version: 4
datadir: data
hierarchy:
- name: "Default docker configuration data"
backend: yaml
paths:
- "os/%{facts.os.family}/%{facts.os.name}/%{facts.os.release.major.minor}.yaml"
- "os/%{facts.os.family}/%{facts.os.name}.yaml"
- "os/%{facts.os.family}/%{facts.os.distro.codename}.yaml"
- "os/%{facts.os.family}.yaml"
- "common.yaml"
93 changes: 6 additions & 87 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -299,10 +299,6 @@
# Specify a custom docker command name
# Default is set on a per system basis in docker::params
#
# [*daemon_subcommand*]
# Specify a subcommand/flag for running docker as daemon
# Default is set on a per system basis in docker::params
#
# [*docker_users*]
# Specify an array of users to add to the docker group
# Default is empty
Expand Down Expand Up @@ -359,28 +355,10 @@
class docker(
$version = $docker::params::version,
$ensure = $docker::params::ensure,
$prerequired_packages = $docker::params::prerequired_packages,
$docker_ce_start_command = $docker::params::docker_ce_start_command,
$docker_ce_package_name = $docker::params::docker_ce_package_name,
$docker_ce_source_location = $docker::params::package_ce_source_location,
$docker_ce_key_source = $docker::params::package_ce_key_source,
$docker_ce_key_id = $docker::params::package_ce_key_id,
$docker_ce_release = $docker::params::package_ce_release,
$docker_package_location = $docker::params::package_source_location,
$docker_package_key_source = $docker::params::package_key_source,
$docker_package_key_check_source = $docker::params::package_key_check_source,
$docker_package_key_id = $docker::params::package_key_id,
$docker_package_release = $docker::params::package_release,
$docker_engine_start_command = $docker::params::docker_engine_start_command,
$docker_engine_package_name = $docker::params::docker_engine_package_name,
$docker_ce_channel = $docker::params::docker_ce_channel,
$docker_ee = $docker::params::docker_ee,
$docker_ee_package_name = $docker::params::package_ee_package_name,
$docker_ee_source_location = $docker::params::package_ee_source_location,
$docker_ee_key_source = $docker::params::package_ee_key_source,
$docker_ee_key_id = $docker::params::package_ee_key_id,
$docker_ee_repos = $docker::params::package_ee_repos,
$docker_ee_release = $docker::params::package_ee_release,
$docker_daemon_command = $docker::params::docker_daemon_command,
$docker_command = $docker::params::docker_command,
$package_repository = lookup('docker::package_repository'),
$prerequired_packages = lookup('docker::prerequired_packages'),
$tcp_bind = $docker::params::tcp_bind,
$tls_enable = $docker::params::tls_enable,
$tls_verify = $docker::params::tls_verify,
Expand All @@ -401,10 +379,6 @@
$log_driver = $docker::params::log_driver,
$log_opt = $docker::params::log_opt,
$selinux_enabled = $docker::params::selinux_enabled,
$use_upstream_package_source = $docker::params::use_upstream_package_source,
$pin_upstream_package_source = $docker::params::pin_upstream_package_source,
$apt_source_pin_level = $docker::params::apt_source_pin_level,
$package_release = $docker::params::package_release,
$service_state = $docker::params::service_state,
$service_enable = $docker::params::service_enable,
$manage_service = $docker::params::manage_service,
Expand Down Expand Up @@ -437,14 +411,11 @@
$dm_override_udev_sync_check = $docker::params::dm_override_udev_sync_check,
$overlay2_override_kernel_check = $docker::params::overlay2_override_kernel_check,
$execdriver = $docker::params::execdriver,
$manage_package = $docker::params::manage_package,
$package_source = $docker::params::package_source,
$manage_epel = $docker::params::manage_epel,
$manage_package = true,
$service_name = $docker::params::service_name,
$docker_users = [],
$docker_group = $docker::params::docker_group,
$daemon_environment_files = [],
$repo_opt = $docker::params::repo_opt,
$nowarn_kernel = $docker::params::nowarn_kernel,
$os = $docker::params::os,
$storage_devs = $docker::params::storage_devs,
Expand All @@ -470,7 +441,7 @@
) inherits docker::params {

validate_string($version)
validate_re($::osfamily, '^(Debian|RedHat|Archlinux|Gentoo)$',
validate_re($facts['os']['family'], '^(Debian|RedHat|Archlinux|Gentoo)$',
'This module only works on Debian or Red Hat based systems or on Archlinux as on Gentoo.')
validate_bool($manage_kernel)
validate_bool($manage_package)
Expand Down Expand Up @@ -546,58 +517,6 @@
validate_string($tls_key)
}

if ( $version == undef ) or ( $version !~ /^(17[.]0[0-5][.]\d(~|-|\.)ce|1.\d+)/ ) {
if ( $docker_ee) {
validate_string($docker::docker_ee_source_location)
validate_string($docker::docker_ee_key_source)
$package_location = $docker::docker_ee_source_location
$package_key_source = $docker::docker_ee_key_source
$package_key_check_source = true
$package_key = $docker::docker_ee_key_id
$package_repos = $docker::docker_ee_repos
$release = $docker::docker_ee_release
$docker_start_command = $docker::docker_ee_start_command
$docker_package_name = $docker::docker_ee_package_name
} else {
case $::osfamily {
'Debian' : {
$package_location = $docker_ce_source_location
$package_key_source = $docker_ce_key_source
$package_key = $docker_ce_key_id
$package_repos = $docker_ce_channel
$release = $docker_ce_release
}
'Redhat' : {
$package_location = "https://download.docker.com/linux/centos/${::operatingsystemmajrelease}/${::architecture}/${docker_ce_channel}"
$package_key_source = $docker_ce_key_source
$package_key_check_source = true
}
default: {}
}
$docker_start_command = $docker_ce_start_command
$docker_package_name = $docker_ce_package_name
}
} else {
case $::osfamily {
'Debian' : {
$package_location = $docker_package_location
$package_key_source = $docker_package_key_source
$package_key_check_source = $docker_package_key_check_source
$package_key = $docker_package_key_id
$package_repos = 'main'
$release = $docker_package_release
}
'Redhat' : {
$package_location = $docker_package_location
$package_key_source = $docker_package_key_source
$package_key_check_source = $docker_package_key_check_source
}
default : {}
}
$docker_start_command = $docker_engine_start_command
$docker_package_name = $docker_engine_package_name
}

contain 'docker::repos'
contain 'docker::install'
contain 'docker::config'
Expand Down
Loading