【问题标题】:Create multiple directory via Puppet通过 Puppet 创建多个目录
【发布时间】:2016-09-12 09:04:23
【问题描述】:

如何通过 Puppet 创建多个文件?

例如我可以运行:

touch abc{1,2,3,4,5,6,7,8} to create abc1,abc2,abc3....abc8

如何通过 Puppet 运行相同的程序?

【问题讨论】:

    标签: puppet


    【解决方案1】:

    最简单的方法是,您可以通过将数组传递给文件资源来指定文件列表:

    $numbered_files = ["/abc1", "/abc2", "/abc3"]
    file { $numbered_files:
      ensure => file,
    }
    

    要自动构建一个带有特定前缀的文件名数组,那么来自stdlibrange 函数可以轻松做到这一点:

    $numbered_files = range("/abc1", "/abc8")
    file { $numbered_files:
      ensure => file,
    }
    

    【讨论】:

      猜你喜欢
      • 2011-11-27
      • 1970-01-01
      • 1970-01-01
      • 2021-11-26
      • 2016-09-20
      • 2017-10-15
      • 2022-09-23
      • 1970-01-01
      • 2021-02-24
      相关资源
      最近更新 更多