2017-07-19 88 views
0

我现在有一个非常基本的食谱。为什么厨师食谱运行两次?

include_recipe 'apache2' 

Chef::Log.info(node[:inewebapp][:apache]); 
node[:inewebapp][:apache].each do |vhost| 
    Chef::Log.info("Currently on host #{vhost['docroot_dir']}"); 
end 

我试图弄清楚 - 当建立这个与测试厨房 - 我得到像我的食谱正在多次运行的日志消息?

这是kitchen converge server

Installing Cookbook Gems: 
    Compiling Cookbooks... 
    /tmp/kitchen/cache/cookbooks/hostsfile/resources/entry.rb:35: warning: constant ::Fixnum is deprecated 
    [2017-07-19T15:36:05+00:00] INFO: [{"docroot_dir"=>"/var/www/host1", "server_name"=>"host1"}, {"docroot_dir"=>"/var/www/host2", "server_name"=>"host2"}] 
    [2017-07-19T15:36:05+00:00] INFO: [{"docroot_dir"=>"/var/www/host1", "server_name"=>"host1"}, {"docroot_dir"=>"/var/www/host2", "server_name"=>"host2"}] 
    [2017-07-19T15:36:05+00:00] INFO: Currently on host /var/www/host1 
    [2017-07-19T15:36:05+00:00] INFO: Currently on host /var/www/host1 
    [2017-07-19T15:36:05+00:00] INFO: Currently on host /var/www/host2 
    [2017-07-19T15:36:05+00:00] INFO: Currently on host /var/www/host2 

输出我没有attributes/default.rb文件是空的,我的.kitchen.yml看起来像这样

--- 
    driver: 
    name: vagrant 

    provisioner: 
    name: chef_zero 
    product_name: chef 
    product_version: 13.0.118 
    log_level: info 

    verifier: 
    name: inspec 

    platforms: 
    - name: ubuntu-16.04 

    suites: 
    - name: server 
     run_list: 
     - recipe[apt] 
     - recipe[ine-webapp::apache] 
     verifier: 
     inspec_tests: 
      - test/integration/server 
     attributes: 
     inewebapp: 
      user: 'vagrant' 
      apache: 
      - docroot_dir: /var/www/host1 
       server_name: host1 
      - docroot_dir: /var/www/host2 
       server_name: host2 

我知道我的食谱应该是幂等,但我不是确定为什么我的配方被执行两次?

更新

经过仔细研究我的kitchen converge server它看起来像厨师客户端的多个实例的输出是正在运行?仍然不明白为什么?

 Transferring files to <server-ubuntu-1604> 
    [2017-07-19T15:58:59+00:00] INFO: Started chef-zero at chefzero://localhost:8889 with repository at /tmp/kitchen, /tmp/kitchen 
    One version per cookbook 

    [2017-07-19T15:58:59+00:00] INFO: Started chef-zero at chefzero://localhost:8889 with repository at /tmp/kitchen, /tmp/kitchen 
    One version per cookbook 

    [2017-07-19T15:58:59+00:00] INFO: Forking chef instance to converge... 
    [2017-07-19T15:58:59+00:00] INFO: Forking chef instance to converge... 
    Starting Chef Client, version 13.0.118 
    [2017-07-19T15:58:59+00:00] INFO: *** Chef 13.0.118 *** 
    [2017-07-19T15:58:59+00:00] INFO: *** Chef 13.0.118 *** 
    [2017-07-19T15:58:59+00:00] INFO: Platform: x86_64-linux 
    [2017-07-19T15:58:59+00:00] INFO: Platform: x86_64-linux 
    [2017-07-19T15:58:59+00:00] INFO: Chef-client pid: 14491 
    [2017-07-19T15:58:59+00:00] INFO: Chef-client pid: 14491 
    [2017-07-19T15:58:59+00:00] INFO: The plugin path /etc/chef/ohai/plugins does not exist. Skipping... 
    [2017-07-19T15:58:59+00:00] INFO: The plugin path /etc/chef/ohai/plugins does not exist. Skipping... 
    [2017-07-19T15:59:00+00:00] INFO: Setting the run_list to ["recipe[apt]", "recipe[ine-webapp::apache]"] from CLI options 
    [2017-07-19T15:59:00+00:00] INFO: Setting the run_list to ["recipe[apt]", "recipe[ine-webapp::apache]"] from CLI options 
    [2017-07-19T15:59:00+00:00] INFO: Run List is [recipe[apt], recipe[ine-webapp::apache]] 
    [2017-07-19T15:59:00+00:00] INFO: Run List is [recipe[apt], recipe[ine-webapp::apache]] 
    [2017-07-19T15:59:00+00:00] INFO: Run List expands to [apt, ine-webapp::apache] 
    [2017-07-19T15:59:00+00:00] INFO: Run List expands to [apt, ine-webapp::apache] 
    [2017-07-19T15:59:00+00:00] INFO: Starting Chef Run for server-ubuntu-1604 
    [2017-07-19T15:59:00+00:00] INFO: Starting Chef Run for server-ubuntu-1604 
    [2017-07-19T15:59:00+00:00] INFO: Running start handlers 
    [2017-07-19T15:59:00+00:00] INFO: Running start handlers 
    [2017-07-19T15:59:00+00:00] INFO: Start handlers complete. 
    [2017-07-19T15:59:00+00:00] INFO: Start handlers complete. 
    resolving cookbooks for run list: ["apt", "ine-webapp::apache"] 

只有一个实例在我的厨房名单

chef-repo/cookbooks/ine-webapp$ kitchen list 
    Instance   Driver Provisioner Verifier Transport Last Action Last Error 
    server-ubuntu-1604 Vagrant ChefZero  Inspec Ssh  Converged <None> 

回答

0

我们不知道是什么原因造成的双重记录呢,只是它似乎是不够的一致调试:(如果您可以拿出一个最小的repro案件,请让我们知道,否则它有时会消失。