Puppet 4.2 puppet agent仅在master重启后才会获得更改

时间:2015-07-04 11:32:30

标签: puppet

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

这应该是在单独的主服务器和节点VM上进行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

e.g。

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'用户一样,我希望在编译后出现的更改不存在。

所以似乎代理的提取过程很好,但却提取过时的信息。 只有在我停止并启动木偶主服务时才会刷新 - 而不是在编译之后。

所以我似乎缺少执行一个由重启木偶主进程执行的步骤。

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

凯文

---编辑---

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

如果我: [root @ cs1 Desktop]#puppet agent -t 信息:检索插件 信息:检索插件 信息:cs1.home的缓存目录 信息:应用配置版本'1436032639' 注意:应用目录在0.02秒内完成 [root @ cs1桌面]#

然后在大师使用: 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 < / p>

- 编辑2 -

仅供参考,在运行puppet agent时,我从服务器发送的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 7月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 7月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

2 个答案:

答案 0 :(得分:0)

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

答案 1 :(得分:0)

问题: 当我们在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

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

    1. puppet agent -t --environment = TEST
    2. 您将看到您的更改已应用。

      线程帮助我找到解决方案

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