Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable Molecule idempotence check on Ansible role test?

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.

like image 395
Kiarash Zamanifar Avatar asked Aug 01 '17 03:08

Kiarash Zamanifar


People also ask

What is molecule test in Ansible?

Molecule project is designed to aid in the development and testing of Ansible roles. Molecule provides support for testing with multiple instances, operating systems and distributions, virtualization providers, test frameworks and testing scenarios.

What is Ansible Idempotent?

Idempotent: An action which, when performed multiple times, has no further effect on its subject after the first time it is performed. In simple words, it means that if any module runs the first time then it should not run again. This will save our CPU time. So, we need to have every module idempotent in nature.

How does molecule work Ansible?

Molecule is a complete testing framework that helps you develop and test Ansible roles, which allows you to focus on the content instead of focusing on managing testing infrastructure. According to its official documentation, Molecule is a project: “designed to aid in the development and testing of Ansible roles.


1 Answers

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

test_sequence:
  - destroy
  - create
  - converge
  # - idempotence
  - lint
  - verify
like image 57
techraf Avatar answered Oct 28 '22 03:10

techraf