【问题标题】:How would i use nested classes in Puppet for this example?在这个例子中,我将如何在 Puppet 中使用嵌套类?
【发布时间】:2015-03-26 20:41:54
【问题描述】:

我正在尝试从 forge 为 puppet 安装 mysqltuner,已经正确安装了 mysql 模块,但我不太了解类的行为。 示例如下:

class drupal::db {

  class { '::mysql::server':

    # how would i access to ::mysql::server::mysqltuner??? 
    # how  do i should nest to make it work???
    # how can i access the subclass of server "mysqltuner"??? what connector should i use???, I know it like some kind of path to the subclass.
    # Which is the magic connector????
    # Class Tested                        It works
    # ::mysql::server::mysqltuner            No
    # ::mysqltuner                           No
    # mysqltuner                             No
    class { '::mysql::server::mysqltuner':  
      ensure => present
    }
  }

  class { '::mysql::client':
  ...
  }
}

我尝试了几种方法,但都没有奏效。 我必须使用我自己的 cfg 文件,并且我需要加载 mysqltuner 以便它与我的文件一起使用。 我非常感谢该主题的任何答案。

亲切的问候。

拉米罗

【问题讨论】:

    标签: mysql class automation puppet mysqltuner


    【解决方案1】:

    你想多了。 mysql::server::mysqltuner 不是嵌套类。这只是一个代表mysql::server意义的名字。

    试试

    include ::mysql::server
    include ::mysql::server::mysqltuner
    

    如果不需要,一般应避免使用class { '::mysql::server': } 语法。

    【讨论】:

    • 抱歉延迟回答,我将如何传递参数,如在这种类型的实现中删除 mysql 帐户???。提前感谢您帮助我
    • @Kouen 执行此操作的首选方法是将include 与适当的Hiera data 结合使用。如果这不是一个选项,您当然可以将 include 声明替换为 class { 'name': } 声明,但请注意有一些 caveats
    • 感谢@Felix-frank 提供数据。问候
    猜你喜欢
    • 1970-01-01
    • 2019-10-16
    • 2017-12-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多