2017-04-25 51 views
1

我必须使用厨师食谱来启动多个tomcat实例。我想在每个实例中定义2个端口 - “http_port”和“shutdown_port”。厨师:如何将散列数组传递给资源

我已经定义在我的属性哈希default.rb作为

default['my_cookbook']['instances'] = Hash.new 

我有2个问题:

  1. 如何提实例在我kitchen.yaml细节? .kitchen.yaml片断
my_cookbook: 
    instances: 
    http_port: 8081 
    shutdown_port: 8082 
    http_port: 1212 
    shutdown_port: 1234
  • 如何通过密钥,对于每一个实例,以我的资源值?
  • +0

    你得到任何答案 - 如何通过关键,值对每个实例到我的资源? –

    回答

    0

    要覆盖kitchen.yml中的节点属性,请使用suites功能。

    suites: 
        - name: node1 
        run_list: 
         - recipe[your_cookbook] 
        attributes: 
         my_cookbook: 
         instances: 
          http_port: 8081 
          shutdown_port: 8082 
        - name: node2 
        run_list: 
         - recipe[your_cookbook] 
        attributes: 
         my_cookbook: 
         instances: 
          http_port: 1212 
          shutdown_port: 1234 
    

    有关详细信息,请参阅: http://kitchen.ci/docs/getting-started/adding-suite