【问题标题】:Puppet 4.2 puppet agent only gets changes after master restartedPuppet 4.2 puppet agent 仅在 master 重新启动后才获得更改
【发布时间】:2015-09-22 01:56:45
【问题描述】:

简而言之,对 site.pp 的更改仅在 puppet master 重新启动后才会反映在代理上。

这应该是一个 OOTB 安装在单独的主虚拟机和节点虚拟机上,配置更改最少 - 基本上是 dns_alt_names 和 /etc/hosts + 证书)。 master和node之间没有coms问题。

在我的主人我有一个文件, /etc/puppetlabs/code/environments/production/manifests/site.pp 包含:

 node "slave1.home" {
   user { "kevin":
      ensure     => present,
      membership => minimum,
      shell      => "/bin/bash",
   }

 }

在代理节点上运行 puppet agent -t 后(并且仅在主节点重新启动后才捕获)更改会受到影响。我可以看到文件已从主节点传输到该位置的代理节点, /opt/puppetlabs/puppet/cache/client_data/catalog/slave1.home.json 其中包含用户“kevin”的详细信息,并且用户已成功创建。

如果我更改 puppet master 上的 site.pp(例如,用户现在是“kevino22y”)然后我(可能错误地)尝试为节点 slave1.home 进行编译

例如

puppet master --compile slave1.home

在我看到的终端上

Notice: Compiled catalog for slave1.home in environment production in 0.28 seconds
{
  "tags": ["settings","slave1.home","node"],
  "name": "slave1.home",
  "version": 1436006611,
  "environment": "production",
  "resources": [
  {
      "type": "Stage",
      "title": "main",
      "tags": ["stage"],
      "exported": false,
      "parameters": {
      "name": "main"
  }
  },
  {
      "type": "Class",
      "title": "Settings",
      "tags": ["class","settings"],
      "exported": false
  },
  {
      "type": "Class",
      "title": "main",
      "tags": ["class"],
      "exported": false,
      "parameters": {Notice: Compiled catalog for slave1.home in environment        production in 0.28 seconds
{
  "tags": ["settings","slave1.home","node"],
  "name": "slave1.home",
  "version": 1436006611,
  "environment": "production",
  "resources": [
    {
      "type": "Stage",
      "title": "main",
      "tags": ["stage"],
      "exported": false,
      "parameters": {
         "name": "main"
      }
    },
    {
      "type": "Class",
      "title": "Settings",
      "tags": ["class","settings"],
      "exported": false
    },
   {
     "type": "Class",
     "title": "main",
     "tags": ["class"],
     "exported": false,
     "parameters": {
      "name": "main"
    }
   },
   {
      "type": "Node",
      "title": "slave1.home",
      "tags": ["node","slave1.home","class"],
      "exported": false
    },
    {
      "type": "User",
      "title": "kevino22y",
      "tags": ["user","kevino22y","node","slave1.home","class"],
      "file":      "/etc/puppetlabs/code/environments/production/manifests/site.pp",
      "line": 2,
      "exported": false,
      "parameters": {
      "ensure": "present",
      "membership": "minimum",
      "shell": "/bin/bash"
     }
   }
  ],
  "edges": [
    {
     "source": "Stage[main]",
     "target": "Class[Settings]"
   },
   {
     "source": "Stage[main]",
     "target": "Class[main]"
   },
   {
     "source": "Class[main]",
     "target": "Node[slave1.home]"
   },
   {
     "source": "Node[slave1.home]",
     "target": "User[kevino22y]"
   }
 ],
 "classes": [
   "settings",
   "slave1.home"
 ]
}

如果我然后返回我的 slave1.home 并运行, 傀儡特工-t

我看到了原件的新副本 /opt/puppetlabs/puppet/cache/client_data/catalog/slave1.home.json 使用原始的“kevin”用户,所以我期望在编译后出现的更改不存在。

所以看起来代理的获取过程很好,但是获取了过时的信息。 只有当我停止并启动 puppet master 服务时它才会刷新 - 而不是在编译之后。

因此,我似乎进一步错过了通过重新启动 puppet master 进程来执行的步骤。

当有人告诉我我错过了什么时,我可能会踢自己。 感谢您对新手问题的帮助。

凯文

---编辑---

仍在尝试诊断并添加新服务器(称为 cs1 的代理)

如果我: [root@cs1 桌面]# 木偶代理 -t 信息:检索插件事实 信息:检索插件 信息:cs1.home 的缓存目录 信息:应用配置版本“1436032639” 注意:0.02秒内应用目录 [root@cs1 桌面]#

然后在master上使用: puppet master --no-daemonize --debug >/tmp/master.txt 并跟踪日志

Debug: Routes Registered:
Debug: Route /^\/puppet\//
Debug: Route /^\/puppet-ca\//
Debug: Route /.*/
Debug: Evaluating match for Route /^\/puppet\//
Debug: Evaluating match for Route /v3/
Debug: Evaluating match for Route /^\/environments$/
Debug: Did not match path ("/node/cs1.home")
Debug: Evaluating match for Route /.*/
Info: Caching node for cs1.home
Debug: Puppet::Network::Format[msgpack]: feature msgpack is missing
Debug: node supports formats: pson yaml binary
Debug: Routes Registered:
Debug: Route /^\/puppet\//
Debug: Route /^\/puppet-ca\//
Debug: Route /.*/
Debug: Evaluating match for Route /^\/puppet\//
Debug: Evaluating match for Route /v3/
Debug: Evaluating match for Route /^\/environments$/
Debug: Did not match path ("/file_metadatas/pluginfacts")
Debug: Evaluating match for Route /.*/
Debug: Warning: calling Plugins.search with empty module path.
Debug: Puppet::Network::Format[msgpack]: feature msgpack is missing
Debug: file_metadata supports formats: pson yaml binary
Debug: Routes Registered:
Debug: Route /^\/puppet\//
Debug: Route /^\/puppet-ca\//
Debug: Route /.*/
Debug: Evaluating match for Route /^\/puppet\//
Debug: Evaluating match for Route /v3/
Debug: Evaluating match for Route /^\/environments$/
Debug: Did not match path ("/file_metadatas/plugins")
Debug: Evaluating match for Route /.*/
Debug: Warning: calling Plugins.search with empty module path.
Debug: Puppet::Network::Format[msgpack]: feature msgpack is missing
Debug: file_metadata supports formats: pson yaml binary
Debug: Routes Registered:
Debug: Route /^\/puppet\//
Debug: Route /^\/puppet-ca\//
Debug: Route /.*/
Debug: Evaluating match for Route /^\/puppet\//
Debug: Evaluating match for Route /v3/
Debug: Evaluating match for Route /^\/environments$/
Debug: Did not match path ("/catalog/cs1.home")
Debug: Evaluating match for Route /.*/
Info: Caching node for cs1.home
Notice: Compiled catalog for cs1.home in environment production in 0.00 seconds
Debug: Puppet::Network::Format[msgpack]: feature msgpack is missing
Debug: catalog supports formats: pson yaml dot binary
Debug: Routes Registered:
Debug: Route /^\/puppet\//
Debug: Route /^\/puppet-ca\//
Debug: Route /.*/
Debug: Evaluating match for Route /^\/puppet\//
Debug: Evaluating match for Route /v3/
Debug: Evaluating match for Route /^\/environments$/
Debug: Did not match path ("/report/cs1.home")
Debug: Evaluating match for Route /.*/
Debug: Received report to process from cs1.home
Debug: Processing report from cs1.home with processor Puppet::Reports::Store

我不完全确定“.home”的来源。我在互联网上读到它可能是由家庭路由器(?)安装的,但我的 fqdn 的格式为 cs1.localdomain 但 /etc/hosts 包含 xxx.xxx.xxx.xxx cs1.localdomain cs1 cs1.home

-- 编辑2--

仅供参考,在运行 puppet agent -t 时,我从服务器获得了 5 个文件,这些文件不反映编译后的更改。

[root@cs1 Desktop]# find /opt/puppetlabs/ -type f -mmin -3 -exec ls -al {} \; -rw-rw---- 1 root root 1290 Jul 6 14:56 /opt/puppetlabs/puppet/cache/client_data/catalog/cs1.home.json -rw-r----- 1 root root 7628 Jul 6 14:56 /opt/puppetlabs/puppet/cache/state/last_run_report.yaml -rw-r----- 1 root root 29 Jul 6 14:56 /opt/puppetlabs/puppet/cache/state/resources.txt -rw-r--r-- 1 root root 407 Jul 6 14:56 /opt/puppetlabs/puppet/cache/state/last_run_summary.yaml -rw-rw---- 1 root root 3655 Jul 6 14:56 /opt/puppetlabs/puppet/cache/state/state.yaml -rw-r----- 1 root root 18 Jul 6 14:56 /opt/puppetlabs/puppet/cache/state/classes.txt

【问题讨论】:

  • 您在编辑清单后等待多长时间?
  • 我可以让它过夜。由于我只是在测试,所以我将频率设置为 5m
  • 我可以让它过夜。因为我只是在测试,所以我将频率设置为 5m。我只是将其更改为 30(持续 30 秒以查看是否有所不同)但没有效果。编译写入标准输出,但它也必须重定向到一个文件,以便在主服务器重新启动时对其进行处理。
  • 这可能是caching 的问题吗?
  • 我也遇到了同样的问题,你能找到解决办法吗?这几天我的头在墙上敲,即使在我的nodes.pp或site.pp中添加通知,我仍然无法得到它适用于我的测试主机,直到我重新启动我的 puppet master

标签: puppet


【解决方案1】:

问题: 当我们在 environment=production 下进行更改时,我们总是必须重新启动 puppet master,否则将不会选择新的更改。

为什么?因为在 puppet master /etc/puppet/puppet.conf environment_timeout = unlimited 。 如果我们想改变这种行为,我们必须设置 environment_timeout = 0

关于 environment_timeout = 无限制 此设置指定 puppet master 将缓存目录,它的存在是为了提高性能。

但在测试环境中,我们经常希望看到我们的更改立即应用。

要做到这一点,在 puppet master 上做两件事,

  1. 在您的环境目录下创建一个 environment.conf,例如 /etc/puppet/environment/TEST

  2. 添加 environment_timeout = 0

在 puppet 客户端(您要应用目录的地方)执行此操作。

  1. 傀儡代理-t --environment=TEST

您将看到您的更改已应用。

线程帮我找到解决方案

(a) 环境配置: https://docs.puppet.com/puppet/3.7/environments_configuring.html

【讨论】:

    【解决方案2】:

    出现这种情况是因为对 puppet master 上的网络配置进行了更改。网络服务已重新启动并手动验证更改(例如主机名和对 /etc/hosts 的更改)。解决办法就是重启 puppet master。

    【讨论】:

      猜你喜欢
      • 2015-03-24
      • 2017-05-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多