Ale*_*x F 6 configuration configuration-management puppet
我试图说明的用例是什么时候用默认配置声明一些项目(eq mysqld 服务),该配置可以包含在每个节点上(示例中的类剥离,对于 basenode),并且仍然能够在一些特定的类(例如 mysql::server),被特定节点包含(例如 myserver.local)
我用下面的例子说明了这个用例,我想在所有节点上禁用 mysql 服务,但在特定节点上激活它。但是当然,Puppet 解析失败了,因为 Service[mysql] 被包含了两次。当然,类 mysql::server 与类 stripdown 的子类无关
有没有办法覆盖服务[“mysql”],或将其标记为主要服务,或其他什么?我正在考虑虚拟项目和实现功能,但它只允许多次应用一个项目,而不是重新定义或覆盖。
# In stripdown.pp :
class stripdown {
service {"mysql": enable => "false", ensure => "stopped" }
}
# In mysql.pp :
class mysql::server {
service { mysqld:
enable => true,
ensure => running,
hasrestart => true,
hasstatus => true,
path => "/etc/init.d/mysql",
require => Package["mysql-server"],
}
}
# Then nodes in nodes.pp :
node basenode {
include stripdown
}
node myserver.local inherits basenode {
include mysql::server` # BOOM, fails here because of Service["mysql"] redefinition
}
Run Code Online (Sandbox Code Playgroud)
尝试一下
# In stripdown.pp :
class stripdown {
service { "mysql":
enable => "false",
ensure => "stopped"
}
}
# In mysql.pp :
class mysql::server inherits stripdown {
Service["mysqld"] {
enable => true,
ensure => running,
hasrestart => true,
hasstatus => true,
path => "/etc/init.d/mysql",
require => Package["mysql-server"],
}
}
# Then nodes in nodes.pp :
node basenode {
include stripdown
}
node myserver.local inherits basenode {
include mysql::server
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11206 次 |
| 最近记录: |