CentOS   发布时间:2022-05-09  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了centos – 管理启用 – 禁用Hiera puppet的nginx网站?大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我得到了实现hiera puppet脚本来管理Nginx的sites_enabled的任务.

这是我的傀儡剧本:

common.yaml

---
classes:
    - Nginx

Nginx:
    enabled:
        abc.com
        xyz.com
    disabled:
        test.com
        test2.com

init.pp

class Nginx{
    create_resources("site_enabled",hiera("Nginx"),{})
}

define site_enabled($Name){
    file { '/etc/Nginx/sites_enabled/${name}':
       ensure => 'link',target => '/etc/Nginx/site_available/${name}',}
}

但是当木偶执行时我得到了错误

我试图通过命令行查询hiera时:

我知道我错了一些地方.请你好好指正.
我不太了解,如何使用数组数据查询和处理.如果可能的话,请指出一些有用的文件.

非常感谢.

你的问题非常类似于 Problems creaTing Hiera hashes for create_resources,它有一个答案.我在这里提供一个回顾.

根据documentation for create_resources,哈希必须采用{title =>形式{parameters}}.您应该编辑hiera数据以设置参数.由于没有,我认为它可能看起来像这样

common.yaml

---
classes:
    - Nginx

Nginx::enabled:
    abc.com: {}
    xyz.com: {}
Nginx::disabled:
    test.com: {}
    test2.com: {}

接下来,您需要实际从hiera加载正确的数据.你想加载Nginx :: enabled,而不是所有的Nginx

init.pp

class Nginx{
    create_resources("site_enabled",hiera("Nginx::enabled"))
}

define site_enabled($Name){
    file { '/etc/Nginx/sites_enabled/${name}':
       ensure => 'link',}
}

大佬总结

以上是大佬教程为你收集整理的centos – 管理启用 – 禁用Hiera puppet的nginx网站?全部内容,希望文章能够帮你解决centos – 管理启用 – 禁用Hiera puppet的nginx网站?所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: