1

私たちのアプリの 1 つは gunicorn を使用しており、chef のクックブックを介して構成されています。

クックブックにはいくつかの属性があり、そのうちの 1 つがガンコーン バージョンです。

grep 'version' attributes/default.rb
default['myapp']['gunicorn']['version'] = '19.1.1'

19.3.0ノードが特定のロールの一部である場合にのみ、バージョンを使用したいと考えています。私は役割を作成し、それに属性を与えました:

cat ../../roles/gunicorn-19.3.0.rb
name 'gunicorn-19.3.0'

default_attributes(
  'mcnulty' => {
    'gunicorn' => {
      'version' => '19.3.0'
    }
  }
)

ロール属性がクックブック属性よりも優先されることを考えると、これは機能するはずです。右??

それでは、キッチンでそれをテストしたいと思います。私たちkichen.ymlにはすでにスイートがありdefaultます。スイートをコピーして作成しましたgunicorn-19.3.0

- name: gunicorn-19.3.0
    roles_path: '../../roles'
    run_list:
      - recipe[apt]
      - recipe[build-essential]
      - recipe[myapp]
    attributes: &attributes
      myapp:
        gunicorn:
          query:
            timeout: 5
            workers: 2
            sockdir: /var/run/myapp
          web:
            timeout: 5
            workers: 2
            sockdir: /var/run/myapp

今、このホストが役割の一部であるという事実を模倣する方法がわかりませんgunicorn-19.3.0...

どんな助けでも大歓迎です。

一番。

4

2 に答える 2

2

役割を test/integration ディレクトリに置くと、chef-zero によって自動的に取得されます。

├── .kitchen.yml
└── test
    └── integration
        └── roles
            └── myrole.json

次に、キッチン ファイルに 2 つのテスト スイートを作成します。1 つはクックブック レシピを使用し、もう 1 つはロールを使用します。

suites:
  - name: default
    run_list:
      - recipe[mycookbook::default]
  - name: withrole
    run_list:
      - role[myrole]

ロールを使用して tomcat 属性を管理する例:

于 2015-08-27T00:15:20.857 に答える
0

マーク、ありがとう。

cat test/integration/roles/gunicorn-19-3-0.json
{
  "name": "gunicorn-19-3-0",
  "override_attributes": {
    "myapp": {
      "gunicorn": {
        "version": "19.3.0"
      }
    }
  }
}

cat .kitchen.yml
 - name: gunicorn-19.3.0
    #roles_path: '../../roles'
    run_list:
      - recipe[apt]
      - recipe[build-essential]
      - recipe[python]
      - recipe[myapp::default]
      - role[gunicorn-19-3-0]
    attributes: &attributes
      myapp:
        gunicorn:
          query:
            timeout: 5
            workers: 2
            sockdir: /var/run/myapp
          web:
            timeout: 5
            workers: 2
            sockdir: /var/run/myapp

kitchen converge、gunicorn 19.3.0 がインストールされます。ありがとう!

于 2015-08-27T12:42:49.487 に答える