question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Molecule idempotence test is not working during standalone execution via Docker

See original GitHub issue

Issue Type

  • Bug report

Molecule and Ansible details

ansible 2.7.9
molecule 2.20.0

Molecule installation method (one of):

  • Using Molecule from Docker image: quay.io/ansible/molecule:2.20

Ansible installation method (one of):

  • Using Ansible from Docker image: quay.io/ansible/molecule:2.20

Detail any linters or test runners used:

Desired Behavior

I’m executing molecule tests by leveraging dind as from docs example. Idempotence scenario cannot find converged instances if I run it as standalone step. Is there are kind of limitation for this for dind execution? Debug also shows not so much information. If I run converge+idempotence scenarious at the same run, all is working OK.

Actual Behaviour

~/test-role$ docker run --rm -it \
>     -v "$(pwd)":/tmp/$(basename "${PWD}"):ro \
>     -v /var/run/docker.sock:/var/run/docker.sock \
>     -w /tmp/$(basename "${PWD}") \
>     quay.io/ansible/molecule:2.20 \
>     molecule create
--> Validating schema /tmp/test-role/molecule/default/molecule.yml.
Validation completed successfully.
--> Test matrix

└── default
    └── create

--> Scenario: 'default'
--> Action: 'create'

    PLAY [Create] ******************************************************************

    TASK [Log into a Docker registry] **********************************************
    skipping: [localhost] => (item=None)

    TASK [Create Dockerfiles from image names] *************************************
    changed: [localhost] => (item=None)
    changed: [localhost]

    TASK [Discover local Docker images] ********************************************
    ok: [localhost] => (item=None)
    ok: [localhost]

    TASK [Build an Ansible compatible image] ***************************************
    changed: [localhost] => (item=None)
    changed: [localhost]

    TASK [Create docker network(s)] ************************************************

    TASK [Determine the CMD directives] ********************************************
    ok: [localhost] => (item=None)
    ok: [localhost]

    TASK [Create molecule instance(s)] *********************************************
    changed: [localhost] => (item=None)
    changed: [localhost]

    TASK [Wait for instance(s) creation to complete] *******************************
    changed: [localhost] => (item=None)
    changed: [localhost]

    PLAY RECAP *********************************************************************
    localhost                  : ok=6    changed=4    unreachable=0    failed=0


~/test-role$ docker run --rm -it \
>     -v "$(pwd)":/tmp/$(basename "${PWD}"):ro \
>     -v /var/run/docker.sock:/var/run/docker.sock \
>     -w /tmp/$(basename "${PWD}") \
>     quay.io/ansible/molecule:2.20 \
>     molecule converge
--> Validating schema /tmp/test-role/molecule/default/molecule.yml.
Validation completed successfully.
--> Test matrix

└── default
    └── converge

--> Scenario: 'default'
--> Action: 'converge'

    PLAY [Converge] ****************************************************************

    TASK [Gathering Facts] *********************************************************
    ok: [molecule-host-]

    TASK [test-role : Ensure test user exists] *************************************
    changed: [molecule-host-]

    PLAY RECAP *********************************************************************
    molecule-host-             : ok=2    changed=1    unreachable=0    failed=0


~/test-role$ docker run --rm -it \
>     -v "$(pwd)":/tmp/$(basename "${PWD}"):ro \
>     -v /var/run/docker.sock:/var/run/docker.sock \
>     -w /tmp/$(basename "${PWD}") \
>     quay.io/ansible/molecule:2.20 \
>     molecule --debug idempotence
--> Validating schema /tmp/test-role/molecule/default/molecule.yml.
Validation completed successfully.
--> Test matrix

└── default
    └── idempotence

--> Scenario: 'default'
--> Action: 'idempotence'
ERROR: Instances not converged.  Please converge instances first.

~/test-role$ docker ps
CONTAINER ID        IMAGE                                                           COMMAND                  CREATED             STATUS              PORTS               NAMES
381ba0afe7e9        molecule_local/centos:latest                                    "/sbin/init"             2 minutes ago       Up 2 minutes                            molecule-host-

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
prashant0085commented, Dec 6, 2019

I guess to check idempotence locally you can execute molecule converge twice coz If I am not wrong molecule idempotence works as running molecule converge two times.

0reactions
ssbarneacommented, Feb 3, 2020

@prashant0085 is right, that is by design. You either disable idempotence or assure that second run does not report any changed tasks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Molecule idempotence test is not working during standalone ...
Issue Type Bug report Molecule and Ansible details ansible 2.7.9 molecule 2.20.0 Molecule installation method (one of): Using Molecule from ...
Read more >
Testing Ansible Automation with Molecule Pt. 2 - Medium
This post will explore running two distinct containers, validate idempotency, and check syntax with linting. You can find the Ansible code we ...
Read more >
How to test Ansible playbook/role using Molecules with Docker
Sometimes during the playbook execution, although it executes playbook fine but it does not give us the desired result so in order to...
Read more >
Configuration — Molecule Documentation
The command to execute is required, and is relative to Molecule's project directory when referencing a script not in $PATH.
Read more >
Offline Installer Testing Guide — onap master documentation
Molecule is designed to test single Ansible role in isolation. Offline ... Offline installer does not have unittest level of testing for the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found