【问题标题】:How to disable Molecule idempotence check on Ansible role test?如何在 Ansible 角色测试中禁用分子幂等性检查?
【发布时间】:2017-11-29 14:48:17
【问题描述】:

使用 Molecule v.2 测试 Ansible 角色时,我遇到了检查角色是否具有幂等性的问题。

如何禁用此检查?

作为documented,需要在molecule.yml文件中设置分子配置参数,但是我找不到如何禁用幂等性检查。

---
# molecule.yml file

dependency:
  name: galaxy
driver:
  name: docker
lint:
  name: ansible-lint
  options:
    x: ANSIBLE0006,ANSIBLE0010,ANSIBLE0012,ANSIBLE0013
platforms:
  - name: mongo01
    image: mongo:3.2
    privileged: yes
    groups:
      - mongodb
      - mongodb_master

  - name: mysql_server
    image: mysql
    environment:
      MYSQL_ROOT_PASSWORD: some_password
    groups:
      - mysql

  - name: elasticsearch
    image: molecule_local/centos:6
    command: sleep infinity
    dockerfile: Dockerfile
    privileged: yes
    groups:
      - elastic

  - name: esb
    image: molecule_local/centos:6
    command: sleep infinity
    dockerfile: Dockerfile
    links:
      - "elasticsearch-default:elasticsearch elasticsearch01"
      - "mongo01-default:mongo mongo_b2b mongo01"
      - "mysql_server-default:mysql mysql_server"
    groups:
      - fabric

provisioner:
  name: ansible
  config_options:
    defaults:
      vault_password_file: /path/to/vault/file
      diff: yes
scenario:
  name: default
# Probably something like below should disable idempotency check.
  idempotent: false
# Uncomment when developing locally to 
# keep instances running when tests are completed. 
# Must be kept commented when building on CI/CD.  
#  test_sequence:
#    - destroy
#    - create
#    - converge
#    - lint
#    - verify
verifier:
  name: testinfra

我想完全摆脱幂等性检查并依赖我自己的测试。

【问题讨论】:

    标签: ansible molecule


    【解决方案1】:

    您应该取消注释 test_sequence 并仅包含您想要的测试,例如:

    test_sequence:
      - destroy
      - create
      - converge
      # - idempotence
      - lint
      - verify
    

    【讨论】:

    • 再次感谢techraf。打算试一试。我猜不出它是幂等的(不是幂等的或......),应该在 test_sequence 下设置,而不是 ansible 配置的一部分。即使使用网站本身的搜索服务,它也绝对不在文档中。
    • 在标题“场景”下描述:molecule.readthedocs.io/en/latest/configuration.html
    • 对我有用 - 请务必在 molecule.ymlscenario 关键字下添加此配置,例如:scenario: name: vagrant-archlinux test_sequence: - lint - destroy - dependency - syntax - create - prepare - converge #- idempotence - side_effect - verify - destroy
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多