如何在Ansible角色测试中禁用分子幂等性检查?

Kia*_*far 5 ansible molecule

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

如何禁用此检查?

作为记录,需要分子的配置参数中设置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
Run Code Online (Sandbox Code Playgroud)

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

tec*_*raf 6

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

test_sequence:
  - destroy
  - create
  - converge
  # - idempotence
  - lint
  - verify
Run Code Online (Sandbox Code Playgroud)

  • 对我有用 - 只需确保在 `scenario` 关键字下的 `molecule.yml` 中添加此配置,例如:`scenario: name: vagrant-archlinux test_sequence: - lint - destroy - dependency - syntax - create - prepare - fusion #- 幂等性 - 副作用 - 验证 - 销毁` (2认同)