How to disable Molecule idempotence check on Ansible role test?
Asked Answered
C

1

9

Using Molecule v.2 to test Ansible roles, I faced an issue with the check for a role to be idempotent.

How can I disable this check?

As documented, Molecule configuration parameters are required to be set in molecule.yml file, but I could not find how to disable idempotence check.

---
# 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

I want to get rid of idempotency check altogether and rely on my own tests.

Collett answered 1/8, 2017 at 3:24 Comment(0)
H
10

You should uncomment the test_sequence and include only the tests you want, for example:

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

Read more: Advanced testing.

Hyperbolize answered 1/8, 2017 at 6:12 Comment(4)
Thank you techraf again. Going to give it a go. I could not guess that it is idempotence (not idempotent or ...) and should be set under test_sequence and not part of ansible configuration. It is definitely not in the document even using the search service of the site itself.Collett
github.com/metacloud/molecule/commit/…Hyperbolize
described here under the caption "scenario": molecule.readthedocs.io/en/latest/configuration.htmlDeil
works for me - just be sure to add this configuration in your molecule.yml under the scenario keyword like: scenario: name: vagrant-archlinux test_sequence: - lint - destroy - dependency - syntax - create - prepare - converge #- idempotence - side_effect - verify - destroyReft

© 2022 - 2024 — McMap. All rights reserved.