这看起来像很多代码,可能更有效(Zesty& Xenial)?我想让它更短更容易管理未来的版本(Ubuntu 18 ....)你能支持谢谢
$mirrors = {
'xenial_main' => {
location => 'http://de.archive.ubuntu.com/ubuntu',
release => 'xenial',
repos => ['main', 'restricted'],
architectures => ['i386','amd64'],
key => ['40976EAF437D05B5','3B4FE6ACC0B21F32'],
keyserver => 'keyserver.ubuntu.com',
with_udebs => true,
},
'xenial_main_updates' => {
location => 'http://de.archive.ubuntu.com/ubuntu',
release => 'xenial-updates',
repos => ['main', 'restricted'],
architectures => ['i386','amd64'],
key => ['40976EAF437D05B5','3B4FE6ACC0B21F32'],
keyserver => 'keyserver.ubuntu.com',
with_udebs => true,
},
'xenial_universe' => {
location => 'http://de.archive.ubuntu.com/ubuntu',
release => 'xenial',
repos => ['universe'],
architectures => ['i386','amd64'],
key => ['40976EAF437D05B5','3B4FE6ACC0B21F32'],
keyserver => 'keyserver.ubuntu.com',
with_udebs => true,
},
'zesty_main' => {
location => 'http://de.archive.ubuntu.com/ubuntu',
release => 'zesty',
repos => ['main', 'restricted'],
architectures => ['i386','amd64'],
key => ['40976EAF437D05B5','3B4FE6ACC0B21F32'],
keyserver => 'keyserver.ubuntu.com',
with_udebs => true,
},
'zesty_main_updates' => {
location => 'http://de.archive.ubuntu.com/ubuntu',
release => 'zesty-updates',
repos => ['main', 'restricted'],
architectures => ['i386','amd64'],
key => ['40976EAF437D05B5','3B4FE6ACC0B21F32'],
keyserver => 'keyserver.ubuntu.com',
with_udebs => true,
}
}
答案 0 :(得分:0)
为什么不使用迭代器?文档:https://puppet.com/docs/puppet/5.3/lang_iteration.html
最基本的版本是:
['xenial','zesty'] = $ubuntu_releases
$ubuntu_releases.each |String $release| {
$mirrors = {
"${release}_main" => {
location => 'http://de.archive.ubuntu.com/ubuntu',
release => $release,
repos => ['main', 'restricted'],
architectures => ['i386','amd64'],
key => ['40976EAF437D05B5','3B4FE6ACC0B21F32'],
keyserver => 'keyserver.ubuntu.com',
with_udebs => true,
},
"${release}_main_updates" => {
location => 'http://de.archive.ubuntu.com/ubuntu',
release => "${release}-updates",
repos => ['main', 'restricted'],
architectures => ['i386','amd64'],
key => ['40976EAF437D05B5','3B4FE6ACC0B21F32'],
keyserver => 'keyserver.ubuntu.com',
with_udebs => true,
},
"${release}_universe" => {
location => 'http://de.archive.ubuntu.com/ubuntu',
release => $release,
repos => ['universe'],
architectures => ['i386','amd64'],
key => ['40976EAF437D05B5','3B4FE6ACC0B21F32'],
keyserver => 'keyserver.ubuntu.com',
with_udebs => true,
},
}
}
但你甚至可以进一步迭代哈希,因为唯一改变的是with_udebs,发布名称和哈希标题?