Add registry_mirror to base::docker profile
This patch adds a new registry_mirror option to help configure /etc/docker/daemon.json so that we can make use of HTTP docker mirrors within upstream TripleO CI (infra). Change-Id: I4b966e9b9b174ca5a6f57974185e0149ea12f232
This commit is contained in:
parent
2ec381a475
commit
936aece1de
@ -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'],
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -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|
|
||||
|
Loading…
Reference in New Issue
Block a user