跳转到内容

共享

跨场景共享

Playbook 和测试可以在不同场景之间共享。

$ tree shared-tests
shared-tests
├── molecule
   ├── centos
      └── molecule.yml
   ├── resources
      ├── playbooks
         ├── Dockerfile.j2 (optional)
         ├── create.yml
         ├── destroy.yml
         ├── converge.yml  # <-- previously called playbook.yml
         └── prepare.yml
      └── tests
          └── test_default.py
   ├── ubuntu
      └── molecule.yml
   └── ubuntu-upstart
       └── molecule.yml

测试和 playbook 可以在不同场景之间共享。

在此示例中,tests 目录位于共享位置,并且 molecule.yml 指向共享的测试。

verifier:
  name: testinfra
  directory: ../resources/tests/

在第二个示例中,动作 createdestroyconvergeprepare 从共享目录加载。

provisioner:
  name: ansible
  playbooks:
    create: ../resources/playbooks/create.yml
    destroy: ../resources/playbooks/destroy.yml
    converge: ../resources/playbooks/converge.yml
    prepare: ../resources/playbooks/prepare.yml