How to customise a tomcat recipe in Chef

前端 未结 1 622
天涯浪人
天涯浪人 2020-12-12 00:08

I\'ve been trying to customise a tomcat chef recipe but nothing I\'m doing seems to change the tomcat installation. I\'m using vagrant ie.

vagrant destroy &         


        
相关标签:
1条回答
  • 2020-12-12 00:50

    Author's Message

    This answer is now 5 years old. It may not apply to your scenario today.


    I suspect you're writing your own tomcat cookbook? The node attribute overrides only work with the open source cookbooks documented here:

    • java
    • tomcat

    Example

    This is a test kitchen example that leverages vagrant.

    ├── .kitchen.yml
    ├── Berksfile
    └── test
        └── integration
            ├── default
            │   └── serverspec
            │       └── tomcat_spec.rb
            └── roles
                └── tomcat.json
    

    The "tomcat" role illustrates how to set the run-list and override the attributes.

    .kitchen.yml

    ---
    driver:
      name: vagrant
    
    provisioner:
      name: chef_zero
    
    platforms:
      - name: ubuntu-14.04
    
    suites:
      - name: default
        run_list:
          - role[tomcat]
        attributes:
    

    test/integration/roles/tomcat.json

    {
      "name": "tomcat",
      "description": "Runs tomcat with oracle JDK",
      "override_attributes": {
        "java": {
          "jdk_version": 8,
          "install_flavor": "oracle",
          "oracle": {
            "accept_oracle_download_terms": true
          }
        },
        "tomcat": {
          "base_version": 7,
          "port": 8081
        }
      },
      "run_list": [
        "recipe[apt]",
        "recipe[java]",
        "recipe[tomcat]"
      ]
    }
    

    Berksfile

    Berkshelf automatically downloads cookbooks from the chef supermarket.

    source 'https://supermarket.chef.io'
    
    cookbook "apt"
    cookbook "java"
    cookbook "tomcat"
    

    test/integration/serverspec/tomcat_spec.rb

    require 'serverspec'
    
    set :backend, :exec
    
    describe service('tomcat7') do
      it { should be_running }
    end
    
    describe port('8081') do
      it { should be_listening }
    end
    
    describe process('java') do
      it { should be_running }
      its(:args) { should match /org.apache.catalina.startup.Bootstrap/ }
    end
    
    0 讨论(0)
提交回复
热议问题