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 need to log the same way ansible does

See original GitHub issue

Issue Type

  • Feature request

Molecule and Ansible details

ansible --version && molecule --version

Molecule installation method (one of):

  • pip

Ansible installation method (one of):

  • pip

Desired Behavior

It could sound as a joke, but molecule need to have the same bugs as ansible. Why we need this ? For example i spend some time to write an ansible role for influxdb Since the module influxdb_user in the ansible core doesn’t behave as I want, i decided to include a custom module in my role and use molecule for every role i write. All went well, my custom module works and is taking over the core module and molecule return OK My CI report a success too

Now my role seems ok, i include it in a playbook and run it and…

TASK [influxdb : [InfluxDB] Create users] ******************************************************************************************************************************************************************
failed: [canoctl_influxdb1] (item={u'user_password': u'[redacted]', u'grants': [{u'privilege': u'ALL', u'database': u'[redacted]'}], u'user_name': u'[redacted]'}) => {"changed": false, "item": {"grants": [{"database": "[redacted]", "privilege": "ALL"}], "user_name": "[redacted]", "user_password": "[redacted]"}, "msg": "Unsupported parameters for (influxdb_user) module: grants Supported parameters include: ********, hostname, password, port, proxies, retries, ssl, state, timeout, udp_port, use_udp, user_name, user_password, username, validate_certs"}

It wasn’t clear at first why it doesn’t works and banging my head a few hours before finding this issue #ansible/ansible/issues/17078

The reason of this bug is obscure and the issue is old but it is clear that molecule use some configuration who allow in his way to bypass this bug.

You will find at least 2 examples in the issue, one is a minimal example of my use case ( creation of docker_containers, then apply my role on them ) who cause the error above but works smoothly on my molecule scenario.

Hope you will find some solution to stick close to the ansible bugs to not let your users believe their roles are ok and publish them on ansible galaxy without them noticing than they are buggy :p

Best regards,

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
rockandskacommented, Mar 6, 2019

@decentral1se , you will find here a reproducible test case who show no errors with molecule but throw one in a similar case without molecule.

test-ko.yml playbook:

  • first play (localhost)
    • create a docker container (molecule does it too in similar way)
    • add it to the inventory
  • second play (localhost)
    • use the role test
      • debug msg
      • use of the custom module
      • debug msg
$ ansible-playbook --version
ansible-playbook 2.7.8
$ ansible-playbook -i localhost, test-ko.yml | grep -A 40 "roles/test"
TASK [roles/test : debug] **********************************************************************************************************************************************************************************
ok: [localhost] => {
    "msg": "In tasks/main.yml in test role"
}

TASK [roles/test : Test custom lib] ************************************************************************************************************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Unsupported parameters for (influxdb_user) module: yourName Supported parameters include: admin, hostname, password, port, proxies, retries, ssl, state, timeout, udp_port, use_udp, user_name, user_password, username, validate_certs"}
	to retry, use: --limit @/home/ypanier/Documents/Git/repro-issues/molecule/molecule/issue_1803/test-ko.retry

PLAY RECAP *************************************************************************************************************************************************************************************************
localhost                  : ok=5    changed=2    unreachable=0    failed=1   

test-ok.yml playbook: (just removed the creation of the container)

  • first play (localhost)
    • add container to the inventory
  • second play (localhost)
    • use the role test
      • debug msg
      • use of the custom module
      • debug msg
$ ansible-playbook -i localhost, test-ok.yml | grep -A 40 "roles/test"
TASK [roles/test : debug] **********************************************************************************************************************************************************************************
ok: [localhost] => {
    "msg": "In tasks/main.yml in test role"
}

TASK [roles/test : Test custom lib] ************************************************************************************************************************************************************************
ok: [localhost]

TASK [roles/test : debug] **********************************************************************************************************************************************************************************
ok: [localhost] => {
    "atest": {
        "changed": false, 
        "failed": false, 
        "msg": "Hello Test"
    }
}

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

Test with molecule is ok with different version of ansible

$  tox | grep -Eo "ansible==.\..\...|\s+molecule-issue-1803.*ok=.*changed.*|py27-ansible..: commands succeeded"
ansible==2.5.15
    molecule-issue-1803        : ok=4    changed=0    unreachable=0    failed=0
ansible==2.6.14
    molecule-issue-1803        : ok=4    changed=0    unreachable=0    failed=0
ansible==2.7.8,
    molecule-issue-1803        : ok=4    changed=0    unreachable=0    failed=0
py27-ansible25: commands succeeded
py27-ansible26: commands succeeded
py27-ansible27: commands succeeded
1reaction
rockandskacommented, Mar 5, 2019

From a discussion with @agaffney on IRC, he think that molecule use an alternate ansible.cfg who add some path to “library” and is the reason for why molecule doesn’t hit this bug. On Ansible side, I didn’t dig in the source code to fully understanding it, but from the issue, it seems that this error is triggered when a core module (even if not related with the custom one) was used with “name” arg before the custom one but is not always the case. NB: this error only happen when the custom module have the same name as the core module. In my example, the module “add_host” use an arg “name” but doesn’t trigger the error when the use of “docker_container” (who have a “name” arg) trigger the error. In @alikins repro example it seems that it is the “name” of the task who trigger the error since “debug” doesn’t have a “name” arg.

So pragmatically, the reasons who seems to trigger the error don’t seem to be related to an ansible.cfg configuration from my point of view, but despite that, it is clear that my role works fine with molecule (with last 2.5,2.6,2.7) when it didn’t work when using directly with a bare ansible without specific path configuration. (tested with last 2.5, 2.6, 2.7)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configuration — Molecule Documentation
Shell is an alternate dependency manager. It is intended to run a command in situations where Ansible Galaxy don't suffice. The command to...
Read more >
Developing and Testing Ansible Roles with Molecule and ...
Molecule is a complete testing framework that helps you develop and test ... the molecule login command to log into one of the...
Read more >
How We Test Our Ansible Roles with Molecule - Zapier
Switch into the project directory and run molecule test to run the initial test case. You'll see a docker container get pulled down,...
Read more >
Molecule for existing Ansible roles - - Rackspace
Because the role already exists, only a scenario needs to be created. A Molecule scenario is the same in this context as it...
Read more >
How to test Ansible playbook/role using Molecules with Docker
The molecule has capabilities to create a VM/Container environment automatically and on top, it will execute your ansible code to verify all its ......
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