我正在通过以下木偶代码设置防火墙服务。我的班级引用数据层次结构来获取数据
class profile::base::firewalld(
Hash $zones = {},
Hash $ports = {},
Hash $services = {},
Hash $rich_rules = {},
Hash $custom_services = {},
Hash $add_services = {},
Hash $remove_services = {},
Array $zone_name = [],
){
class{'firewalld':
zones => $zones,
ports => $ports,
services => $services,
rich_rules => $rich_rules,
custom_services => $custom_services,
}
contain firewalld
#remove firewalld services (ipp-client, samba-client)
$remove_services.each | String $zone, Array[String] $services|{
$services.each | String $service |{
firewalld_service {"${service}":
ensure => absent,
service => $service,
zone => $zone,
}
}
}
#add zone zPrivate zInternet zTier1
$zone_name.each | String $zone_names |{
firewalld_zone{"${zone_names}":
ensure => present,
target => 'default',
purge_rich_rules => true,
purge_services => true,
purge_ports => true,
}
}
我想多次使用此类。例如。如果我想重复使用profile :: base :: firewalld,但是我不知道如何使用差分变量来引用层次数据。有人可以提供我解决问题的好方法。下面的代码是我的方法,但是不起作用
class profile::bs::firewalld(
Hash $zones = {},
Hash $ports = {},
Hash $services = {},
Hash $rich_rules = {},
Hash $custom_services = {},
Hash $add_services = {},
Hash $remove_services = {},
Array $zone_name = [],
){
include profile::base::firewalld
}