木偶重複申報錯誤而延伸的應該管理/etc/network/interfaces
我面臨着以下問題傀儡模塊:使用文件模板和CONCAT
舊模塊剛剛從hiera讀一些增值經銷商,並通過創建一個接口文件模板。 要刪除此限制,我添加了一個散列到包含其他接口及其參數的hiera。通過puppet-concat模塊,我想將它們添加到interfaces文件中。
但是,如果首先爲模板文件和後來的concat文件獲取聲明瞭重複聲明錯誤被拋出。
我該如何首先使用該模板,然後再使用該文件進行concat?或者這是不可能的?
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Evaluation Error: Error while evaluating a Resource Statement, Evaluation Error: Error while evaluating a Resource Statement, Duplicate declaration: ..../modules/lip_network/manifests/debian.pp:16 cannot redeclare at /etc/puppetlabs/code/modules/concat/manifests/init.pp:179 at .../init.pp:179:5 at .../modules/lip_network/manifests/debian.pp:21
類代碼:
class lip_network::debian
{
$ipaddress = $::lip_network::ipaddress
$netmask = $::lip_network::netmask
$gateway = $::lip_network::gateway
$dns1 = $::lip_network::dns1
$domain = $::lip_network::domain
$iface = $::lip_network::iface
package { 'resolvconf':
ensure => latest,
}
file { '/etc/network/interfaces':
mode => '0644',
owner => 'root',
content => template("${module_name}/interfaces.erb"),
}
concat { '/etc/network/interfaces':
ensure => present,
}
$interface_configs = hiera_hash(lip_network_multi_interfaces::interfaces)
$interface_list = keys($interface_configs)
concat::fragment { "test_interfaces":
target => '/etc/network/interfaces',
content => 'auto em0\niface em0 inet static',
order => "10"
}
# apparently /etc/init.d/networking does not regenerate
exec { 'iface restart':
command => "ifdown ${iface} ; ifup ${iface}",
refreshonly => true,
subscribe => File['/etc/network/interfaces'],
}
}
不回答你的問題,但有定義的類型和提供程序模塊,可能會使這更容易? https://github.com/voxpupuli/puppet-network :) –