迭代Puppet(3.1)中的文件

时间:2013-08-07 22:01:24

标签: ruby automation puppet

我正在寻找以下的干版本:

理想情况下,它可能只是一个数组和一个循环。 Puppet的方法是什么?

class hive_cdh4::configs inherits hive_cdh4 {

  define hive_configs () {

    file { "/etc/hive/conf.rr/hive-site.xml": 
      owner   => root,
      group   => root,
      mode    => 664,
      ensure  => present,
      content => template("hive_cdh4/hive-site.xml.erb")
    }

    file { "/etc/hive/conf.rr/hive-exec-log4j.properties": 
      owner   => root,
      group   => root,
      mode    => 664,
      ensure  => present,
      content => template("hive_cdh4/hive-exec-log4j.properties.erb")
    }

    file { "/etc/hive/conf.rr/hive-log4j.properties": 
      owner   => root,
      group   => root,
      mode    => 664,
      ensure  => present,
      content => template("hive_cdh4/hive-log4j.properties.erb")
    }

  }
}

1 个答案:

答案 0 :(得分:1)

这样的事情怎么样:

define hive_config ($file_name = $title, $format = 'properties') {

  file { "/etc/hive/conf.rr/$file_name.$format":
    owner   => root,
    group   => root,
    mode    => '0664',
    ensure  => present,
    content => template("hive_cdh4/$file_name.$format.erb")
  }

}

hive_config {'hive-site':}
hive_config {'hive-exec-log4j':}
hive_config {'hive-log4j':
   format   => 'xml'
}

我在Vagrant规定中快速测试了它,它似乎有用吗?