How can I display the output of a Opscode Chef bash command in my console?

后端 未结 5 1665
傲寒
傲寒 2020-12-31 03:58

I use Vagrant to spawn a standard \"precise32\" box and provision it with Chef so I can test my Node.js code on Linux when I work on a Windows machine. This works fine.

5条回答
  •  無奈伤痛
    2020-12-31 04:38

    Use the live_stream attribute of the execute resource

    execute 'foo' do
      command 'cat /etc/hosts'
      live_stream true
      action :run
    end
    

    Script output will be printed to the console

       Starting Chef Client, version 12.18.31
       resolving cookbooks for run list: ["apt::default", "foobar::default"]
       Synchronizing Cookbooks:
       Converging 2 resources
       Recipe: foobar::default
         * execute[foo] action run
           [execute] 127.0.0.1  default-ubuntu-1604 default-ubuntu-1604
              127.0.0.1 localhost
              127.0.1.1 vagrant.vm  vagrant
              ::1     localhost ip6-localhost ip6-loopback
              ff02::1 ip6-allnodes
              ff02::2 ip6-allrouters
           - execute cat /etc/hosts
    

    https://docs.chef.io/resource_execute.html

提交回复
热议问题