Puppet 如何将类参数写入hiera

Puppet 如何将类参数写入hiera,puppet,hiera,Puppet,Hiera,我刚刚进入hiera,现在已经对它进行了配置,我迁移到hiera的尝试非常困难,因为我无法获得写入语法。有人能帮我把下面的类声明转换成hiera吗 my declare.pp文件中的当前声明: class profile::web { class { 'nsswitch': automount => 'files', hosts => ['files','dns'], } } class { 'sudo': } sudo::conf { 'web-u

我刚刚进入hiera,现在已经对它进行了配置,我迁移到hiera的尝试非常困难,因为我无法获得写入语法。有人能帮我把下面的类声明转换成hiera吗

my declare.pp文件中的当前声明:

class profile::web {
  class { 'nsswitch':
    automount => 'files',
    hosts => ['files','dns'],
  }
}

class { 'sudo': }
    sudo::conf { 'web-users':
    sudo_config_dir => '/etc/sudoers.d/',
    source => 'puppet:///files/web/web-users.conf',
}
谢谢 Dan

简单:

---
nsswitch::automount:  files
nsswitch::hosts:
  - files
  - dns
在hiera文件中;永远不要使用标签

在您的清单中,您可以使用

include nsswitch
或者,您可以使用Hiera_include函数从Hiera加载类列表:

hiera_include('classes')

然后,在Hiera文件中需要一个类数组。

Hiera不是用来声明类的。在hiera中,您存储可以在puppet清单中使用的数据。在puppet中声明一个类,可以使用hiera根据节点名、环境等事实向其提供数据。要创建资源(sudo::conf!),需要使用create_resources函数。为什么不在hiera文件中使用制表符?这是YAML特有的还是JSON(和其他)数据格式特有的?这是YAML特有的东西。解析器将抛出与“从yaml文件中取出那个该死的标签”无关的神秘错误消息