【问题标题】:In Puppet using Hiera, where do I put the files I want to have installed on nodes?在使用 Hiera 的 Puppet 中,我将要安装在节点上的文件放在哪里?
【发布时间】:2014-05-25 19:58:07
【问题描述】:

我知道 puppet 模块总是有一个文件目录,我知道它应该在哪里,并且我已经从自己的手写模块中有效地使用了 source => 语法,但现在我需要学习如何使用 Hiera 部署文件。

我从 saz-sudo 模块开始,我已经阅读了文档,但是我看不到任何关于将 sudoers 文件放在哪里的信息;我要分发的那个。 我不确定是否需要在 /etc/puppetlabs/puppet 中设置站点范围的文件目录,然后在其中为每个模块或其他内容创建子目录。如果我说 source => "puppet:///files/etc/sudoers" ,Hiera 是否知道查看 /etc/puppetlabs/puppet/files/sudo ?我需要在 /etc/hiera.yaml 中添加路径名吗?添加一行-files ?

感谢任何线索。

【问题讨论】:

    标签: puppet hiera


    【解决方案1】:

    我对 puppet 模块的粗略看法,给出了他们使用 hiera 的例子:

    sudo::configs:
    'web':
        'source'    : 'puppet:///files/etc/sudoers.d/web'
    'admins':
        'content'   : "%admins ALL=(ALL) NOPASSWD: ALL"
        'priority'  : 10
    'joe':
        'priority'  : 60
        'source'    : 'puppet:///files/etc/sudoers.d/users/joe'
    

    建议假设您有一个“文件”木偶模块。所以在你的傀儡模块部分:

    mkdir -p files/files/etc/sudoers.d/
    

    把你的文件放在那里。

    解释:

    url 'puppet:///files/etc/sudoers.d/users/joe' 分解如下:

    puppet: protocol
    ///:  Three slashes indicate the source of the file is in a module.
    files: name of the module
    etc/sudoers.d/users/joe:  full path to the file within the module's "files" directory.
    

    【讨论】:

    • 我想我暂时对那个文件 url 发疯了。它不是它正在寻找的模块。模块路径是“puppet:///modules/mod_name/etc”。有问题的是假设您在 puppet master 上有一个“文件”共享设置。有关如何设置的详细信息,请参阅docs.puppetlabs.com/guides/file_serving.html
    【解决方案2】:

    你没有。

    模块(无论是否支持 Hiera)的想法是消除您管理整个 sudoers 文件的需要。相反,您可以管理 sudoers 文件中的每个条目。

    我建议仔细查看documentation。您绝对应该在您的清单中包含 file { "/etc/sudoers": } 资源。

    【讨论】:

      【解决方案3】:

      Hiera 不需要对文件做任何事情。

      Hiera 就像一个变量数据库,并根据您拥有的层次结构为您提供服务器。

      puppet 中的文件,通常通过 source => 等方法访问,但这些文件也使用一些基本结构。

      在大多数情况下,当您调用文件模板时。

      模板可以满足您的需求,以基于该模板自动构建 sudoers。 还有一些模块也支持修改sudoers。

      由你决定。

      在这种情况下,saz 将文件的位置存储在 hiera 中,但实际位置可以是 puppet 中的文件(如模块文件或类似文件)。

      这完全不相关。 阅读puppet file server

      如果您有任何问题,尽管问。

      V

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-04-13
        • 1970-01-01
        • 2012-05-22
        • 2018-11-24
        • 2019-10-21
        • 2012-11-20
        相关资源
        最近更新 更多