已安装Puppet 5,且Puppet代理-t不';不应用更改,并且没有错误

已安装Puppet 5,且Puppet代理-t不';不应用更改,并且没有错误,puppet,Puppet,我在主机和服务器上安装了puppet 5,并从代理安装/签署了证书…现在我想尝试一个简单的代理运行 我遵循了测试Hiera 5的傀儡官方文档(链接如下): 但代理在我运行时从不应用更改: # puppet agent -t Info: Using configured environment 'production' Info: Retrieving pluginfacts Info: Retrieving plugin Info: Caching catalog for xxxxxx.xxx

我在主机和服务器上安装了puppet 5,并从代理安装/签署了证书…现在我想尝试一个简单的代理运行

我遵循了测试Hiera 5的傀儡官方文档(链接如下):

但代理在我运行时从不应用更改:

# puppet agent -t
Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Caching catalog for xxxxxx.xxx.xxx
Info: Applying configuration version '1504530655'
Notice: Applied catalog in 0.04 seconds
在主机上运行puppet apply/[manifest location]/manifest.pp时,它工作正常

我的主人puppet.conf:

[main]
   server = puppet-master-test.xxx.xxx
   dns_alt_names = puppet-master-test.xxx.xxxx
   certificate_revocation = false
   modulepath = /etc/puppetlabs/code/environments/production/modules

   [master]
   certname = puppet-master-test.xxx.xxx
   vardir = /opt/puppetlabs/server/data/puppetserver
   logdir = /var/log/puppetlabs/puppetserver
   rundir = /var/run/puppetlabs/puppetserver
   pidfile = /var/run/puppetlabs/puppetserver/puppetserver.pid
   codedir = /etc/puppetlabs/code
   environment_timeout = unlimited
[main]
    server = puppet-master-test.xxx.xxx

[master]
  certname = puppet-master-test.xxx.xxx

[agent]
        environment = production
        certname = puppet-client.xxx.xxx
        server = puppet-master-test.xxx.xxx
代理的puppet.conf:

[main]
   server = puppet-master-test.xxx.xxx
   dns_alt_names = puppet-master-test.xxx.xxxx
   certificate_revocation = false
   modulepath = /etc/puppetlabs/code/environments/production/modules

   [master]
   certname = puppet-master-test.xxx.xxx
   vardir = /opt/puppetlabs/server/data/puppetserver
   logdir = /var/log/puppetlabs/puppetserver
   rundir = /var/run/puppetlabs/puppetserver
   pidfile = /var/run/puppetlabs/puppetserver/puppetserver.pid
   codedir = /etc/puppetlabs/code
   environment_timeout = unlimited
[main]
    server = puppet-master-test.xxx.xxx

[master]
  certname = puppet-master-test.xxx.xxx

[agent]
        environment = production
        certname = puppet-client.xxx.xxx
        server = puppet-master-test.xxx.xxx
有人能对此提出建议吗? 提前谢谢

编辑:

我创建了一个简单的模块:

#/etc/puppetlabs/code/environments/production/modules/profile/manifests/hiera_test.pp
class profile::test {
  file { '/tmp/hiera_test.txt':
    ensure  => file,
    owner   => root,
    mode => '0755',
  }
}
init.pp:

#/etc/puppetlabs/code/environments/production/modules/profile/manifests/init.pp
include profile::test
我在:/etc/puppetlabs/code/environments/production/manifests/site.pp下有一个site.pp

node 'puppet-client.xxx.xxx' {
  include profile
}
产出:

#puppet config print modulepath --section master --environment production
/etc/puppetlabs/code/environments/production/modules

#puppet config print manifest --section master --environment production
/etc/puppetlabs/code/environments/production/manifests/site.pp
在主机上使用时:

#puppet apply /etc/puppetlabs/code/environments/production/modules/profile/manifests/init.pp
Notice: Compiled catalog for puppet-master-test.xxx.xxx in environment production in 0.07 seconds
Notice: /Stage[main]/Profile::Test/File[/tmp/hiera_test.txt]/ensure: created
Notice: Applied catalog in 0.11 seconds
但是,puppet agent-t on agent不会在/tmp…/tmp权限为1777下创建文件,如果需要更多信息,可以告诉我吗


谢谢。

正如我在评论中一开始所说的,如果在给定的目录运行中,代理没有尝试将任何资源应用到目标机器,并且没有发出任何诊断,那么目标机器已经与提供给它的目录完全同步。代理缓存目录(详细信息取决于Puppet版本),因此您可以检查实际包含的资源。有时困扰傀儡网站(尤其是新网站)的一个问题是,代理收到的目录实际上是空的。这通常可归因于船长处相关舱单集的缺陷

重要的是要理解,主节点从代理环境的站点清单开始构建目录(这不一定是
puppet应用的方式),并且只有通过该过程发现的为给定节点声明的类和资源才会包含在其目录中。了解代理和主机都执行各种形式的缓存也很重要——前者可以在主机不可用时强制配置,后者可以提高容量和性能

假设站点清单中的节点块将相关代理配置为用作其certname的同一标识符指定为节点名,则清单集(尽管确实存在缺陷)不应成功为该目标节点生成空目录。您可以考虑在添加或切换到默认节点块时调试节点名称,即:
node default {
  include profile
}
但是,由于您已将主目录设置为无限制(默认设置),如果您在启动主目录后修改了清单集,则服务器仍可能提供空目录。您可以手动使主服务器的缓存过期,或者更容易地,您可以重新启动主服务器服务。如果愿意,还可以通过将缓存超时设置为0(并重新启动服务)来禁用环境缓存

至于清单集中的缺陷,至少有三个关键问题:

  • Puppet的
    include
    函数声明。为了支持这一点,它可能会导致对清单文件进行评估,但不应将其解释为执行清单的词法插值,即C预处理器的
    #include
    指令。它更类似于Python的
    import
    命令

  • 在站点清单之外,清单不应在顶部范围包含除类或定义的类型定义以外的任何内容。它们尤其不应在该范围内包含类或资源声明;这些清单中的此类声明应仅出现在类或已定义类型定义的主体内。声明可以出现在站点清单内的任何范围内,但在该上下文中,它们通常应该出现在节点块中

  • 为了让Puppet找到类和定义的类型定义,它们必须位于

  • 关于(1),您的站点清单包含一个节点块,该节点块执行
    包含概要文件
    。这声明类“profile”应包含在目标节点的目录中,但不存在此类。Puppet将在清单的内容中查找类定义(
    production/modules/profile/manifests/init.pp
    ),而不是在顶部范围中包含类
    profile::test
    的声明(请参见(2))。目录生成器应故障转移请求类的缺失。如果它没有这样做,则表明它根本没有查看您的节点块(可能节点名称不匹配),或者它使用的是一个缓存版本的环境,而该环境一开始不会遇到该问题(但也不会导致包含所需的类)

    modules/profile/manifests/init.pp
    中,您似乎想要的是

    class profile {
      include profile::test
    }
    
    请注意,
    include
    语句出现在类“profile”的定义中,它是Puppet将在该特定文件中查找的类的名称。这与使用
    puppet apply
    直接应用此清单不同

    或者,您可以完全跳过这个简单的“profile”类,直接让节点块声明“profile::test”,尽管有些人可能会从风格的角度批评这种方法

    但这还不是全部。您确实提供了类
    profile::test
    的可行定义,但您描述了它驻留在名称不对应的文件中。Puppet将无法在
    production/modules/profile/manifests/hiera_test.pp
    中找到它;它需要位于
    生产/modules/profile/manifests/test.pp
    中,而不是(3)。

    如果代理没有(尝试)应用任何更改,则目标机器已与其接收的目录同步。这可能是因为代理接收到一个空目录而发生的。目前没有在th中显示任何内容