aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--manifests/profile/base/docker.pp23
-rw-r--r--manifests/profile/base/docker_registry.pp9
-rw-r--r--manifests/profile/base/etcd.pp2
-rw-r--r--spec/classes/tripleo_profile_base_docker_spec.rb15
4 files changed, 42 insertions, 7 deletions
diff --git a/manifests/profile/base/docker.pp b/manifests/profile/base/docker.pp
index 5e18a85..4797d86 100644
--- a/manifests/profile/base/docker.pp
+++ b/manifests/profile/base/docker.pp
@@ -28,12 +28,17 @@
# Set docker_namespace to INSECURE_REGISTRY, used when a local registry
# is enabled (defaults to false)
#
+# [*registry_mirror*]
+# Configure a registry-mirror in the /etc/docker/daemon.json file.
+# (defaults to false)
+#
# [*step*]
# step defaults to hiera('step')
#
class tripleo::profile::base::docker (
$docker_namespace = undef,
$insecure_registry = false,
+ $registry_mirror = false,
$step = hiera('step'),
) {
if $step >= 1 {
@@ -64,5 +69,23 @@ class tripleo::profile::base::docker (
subscribe => Package['docker'],
notify => Service['docker'],
}
+
+ if $registry_mirror {
+ $mirror_changes = [
+ 'set dict/entry[. = "registry-mirrors"] "registry-mirrors',
+ "set dict/entry[. = \"registry-mirrors\"]/array/string \"${registry_mirror}\""
+ ]
+ } else {
+ $mirror_changes = [ 'rm dict/entry[. = "registry-mirrors"]', ]
+ }
+
+ augeas { 'docker-daemon.json':
+ lens => 'Json.lns',
+ incl => '/etc/docker/daemon.json',
+ changes => $mirror_changes,
+ subscribe => Package['docker'],
+ notify => Service['docker'],
+ }
+
}
}
diff --git a/manifests/profile/base/docker_registry.pp b/manifests/profile/base/docker_registry.pp
index 2f1783d..73fb6e0 100644
--- a/manifests/profile/base/docker_registry.pp
+++ b/manifests/profile/base/docker_registry.pp
@@ -36,13 +36,15 @@ class tripleo::profile::base::docker_registry (
$registry_port = 8787,
$registry_admin_host = hiera('controller_admin_host'),
) {
+
+ include ::tripleo::profile::base::docker
+
# We want a v2 registry
package{'docker-registry':
ensure => absent,
allow_virtual => false,
}
package{'docker-distribution': }
- package{'docker': }
package{'openstack-kolla': }
file { '/etc/docker-distribution/registry/config.yml' :
ensure => file,
@@ -68,9 +70,4 @@ class tripleo::profile::base::docker_registry (
enable => true,
require => Package['docker-distribution'],
}
- service { 'docker':
- ensure => running,
- enable => true,
- require => Package['docker'],
- }
}
diff --git a/manifests/profile/base/etcd.pp b/manifests/profile/base/etcd.pp
index fc4771f..c29c937 100644
--- a/manifests/profile/base/etcd.pp
+++ b/manifests/profile/base/etcd.pp
@@ -46,7 +46,7 @@ class tripleo::profile::base::etcd (
$nodes = hiera('etcd_node_names', []),
$step = hiera('step'),
) {
- if $step >= 1 {
+ if $step >= 2 {
class {'::etcd':
listen_client_urls => "http://${bind_ip}:${client_port}",
advertise_client_urls => "http://${bind_ip}:${client_port}",
diff --git a/spec/classes/tripleo_profile_base_docker_spec.rb b/spec/classes/tripleo_profile_base_docker_spec.rb
index 587cc29..b52fe24 100644
--- a/spec/classes/tripleo_profile_base_docker_spec.rb
+++ b/spec/classes/tripleo_profile_base_docker_spec.rb
@@ -54,6 +54,21 @@ describe 'tripleo::profile::base::docker' do
it_raises 'a Puppet::Error', /You must provide a \$docker_namespace in order to configure insecure registry/
end
+
+ context 'with step 1 and registry_mirror configured' do
+ let(:params) { {
+ :registry_mirror => 'http://foo/bar',
+ :step => 1,
+ } }
+
+ it { is_expected.to contain_class('tripleo::profile::base::docker') }
+ it { is_expected.to contain_package('docker') }
+ it { is_expected.to contain_service('docker') }
+ it {
+ is_expected.to contain_augeas('docker-daemon.json').with_changes(['set dict/entry[. = "registry-mirrors"] "registry-mirrors', "set dict/entry[. = \"registry-mirrors\"]/array/string \"http://foo/bar\""])
+ }
+ end
+
end
on_supported_os.each do |os, facts|