【问题标题】:When does Chef update resources?Chef 何时更新资源?
【发布时间】:2017-10-26 02:36:43
【问题描述】:

我不太确定 Chef 何时更新资源。这是我运行的命令和得到的响应:

sudo chef-client -zr "recipe[workstation]"
[2017-10-03T14:01:26+00:00] WARN: No config file found or specified on command line, using command line options.
Starting Chef Client, version 12.14.89
resolving cookbooks for run list: ["workstation"]
[2017-10-03T14:01:28+00:00] WARN: Cookbook 'cookbooks' is empty or entirely chefignored at /home/centos/cookbooks/cookbooks
Synchronizing Cookbooks:
  - workstation (0.2.1)
Installing Cookbook Gems:
Compiling Cookbooks...
Converging 7 resources
Recipe: workstation::setup
  * yum_package[vim-enhanced] action install (up to date)
  * yum_package[emacs] action install (up to date)
  * yum_package[tree] action install (up to date)
  * yum_package[git] action install (up to date)
  * yum_package[ntp] action install (up to date)
  * template[/etc/motd] action create
    - update content in file /etc/motd from c102c5 to e0c53e
    --- /etc/motd   2017-09-22 16:41:57.273701730 +0000
    +++ /etc/.chef-motd20171003-2405-1ygf6go    2017-10-03 14:01:34.211094244 +0000
    @@ -1,7 +1,7 @@
     This server is the property of Syed
       HOSTNAME: ip-172-31-35-182
       IPADRESS: 172.31.35.182
    -  CPU: 2400.046
    +  CPU: 2400.108
       MEMORY: 1014976kB
       NAME: Syed
    - restore selinux security context
  * service[ntpd] action enable (up to date)
  * service[ntpd] action start
    - start service service[ntpd]

Running handlers:
Running handlers complete
Chef Client finished, 2/8 resources updated in 07 seconds

需要明确的是,我是 Chef 的新手,但似乎每当我运行这个 Chef-Client 命令时,结果都会有所不同,但很多时候它告诉我资源已更新,而我不太清楚自己做了什么改变任何东西。任何帮助都会很棒。谢谢。

【问题讨论】:

  • 模板中的 CPU 行是什么样的?是否使用了变化的值?

标签: chef-infra chef-recipe


【解决方案1】:

这份文档对我了解 Chef 如何收敛很有帮助。

https://coderanger.net/two-pass/

此外,您使用的模板似乎具有时间戳作为其值的一部分,因此该资源将始终更新。

至于 ntpd 以及它为什么需要重新启动.. 没有 Cheffy 的理由说明它不会从上次聚合配方时就开始运行,并且如果不需要,服务资源适当地什么也不做做完了。唯一的解释是收敛之间存在一些外部状态变化;服务器重新启动并且 ntpd 未设置为自动启动,或者某些进程/人员停止了服务。

因为您谈论的是可变响应,所以查看您收到的其他响应的一些示例会很有帮助。但一般来说,如果您预计收敛之间没有状态变化并且您看到资源收敛,您应该感到震惊。

【讨论】:

    猜你喜欢
    • 2022-11-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-12
    • 1970-01-01
    相关资源
    最近更新 更多