New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: Idempotence Plugin #82

Closed
jpooler opened this Issue Jan 7, 2016 · 17 comments

Comments

Projects
None yet
4 participants
@jpooler

jpooler commented Jan 7, 2016

Hi,

I'm getting this error when I run molecule test and can't figure out what I'm doing wrong:

Idempotence test in progress (can take a few minutes)...
Idempotence test failed.
The idempotence plugin was not found or did not provide the required information. Therefore the failure details cannot be displayed.

I did add the callback from https://github.com/metacloud/molecule/blob/master/assets/ansible/plugins/callback/idempotence/idempotence.py to my top level ansible callback directory, unsure if that should actually be in the role i'm running molecule from or if its some weird ansible version problem?

Anyone hit this before?

@retr0h

This comment has been minimized.

Contributor

retr0h commented Jan 7, 2016

Could you provide your molecule.yml? /cc @rgreinho

@jpooler

This comment has been minimized.

jpooler commented Jan 7, 2016

Sure:

from the folder where the role i'm running against is located:


vagrant:
raw_config_args:
- "ssh.insert_key = false"

platforms:
- name: centos7ga
box: centos7ga
box_url: https://github.com/holms/vagrant-centos7-box/releases/download/7.1.1503.001/CentOS-7.1.1503-x86_64-netboot.box

providers:
- name: virtualbox
type: virtualbox

instances:
- name: humber-01
ansible_groups:
- humber
interfaces:
- network_name: private_network
type: dhcp
auto_config: true

from the top-level ansible directory:

ansible:
vault_password_file: ~/.pass
extra_vars:
datadog_install_client: false
datadog_api_key: '0'
private_interface: 'eth0'
internal: "{{ansible_eth0.ipv4.address}}"
external: "{{ansible_eth0.ipv4.address}}"

@retr0h

This comment has been minimized.

Contributor

retr0h commented Jan 7, 2016

Looks like a pretty normal config. Are you running molecule version 1.2.1? We recently did some refactoring of the Idempotence check.

@jpooler

This comment has been minimized.

jpooler commented Jan 7, 2016

I am I am, I had read over the Changelog and seen the changes/upgraded as a result.

molecule -v
1.2.1

I'm running it with --debug now to see if anything else shows up. Going to shelve it for the night after this. will ping again tomorrow. Thanks for the responses tonight!

@rgreinho rgreinho added the question label Jan 7, 2016

@jpooler

This comment has been minimized.

jpooler commented Jan 7, 2016

OK. I have some "progress" as to diagnosing the issue at least.

It seems that the callback plugin directory is hardcoded to:
ANSIBLE_CALLBACK_PLUGINS: /System/Library/Frameworks/Python.framework/Versions/2.7/share/molecule/ansible/plugins/callback/idempotence

Which doesn't exist natively on OSX for some reason? I installed molecule via pip, but also have the source checked out in my local repo. When I do "pip list | grep molecule" I get:

molecule (1.2.1, /Users/jarrod/Tools/git/molecule)

I tried manually exporting the path to where I'd stashed the callback plugin, which molecule appended the value above to afterwards (and still failed).

Note I am just running this natively, not in a virtualenv. Though I just tried it in a virtualenv and still hit this issue.

I tried passing this as a raw_env_var in my top-level molecule.yml file

raw_env_vars:
ANSIBLE_CALLBACK_PLUGINS: /Users/jarrod/Tools/git/am-dec8/callback_plugins

and experienced the behavior above, where it appends the default.

I'm going to try using a template to overwrite the .molecule/ansible.cfg next.

@rgreinho

This comment has been minimized.

Contributor

rgreinho commented Jan 7, 2016

The idempotence.py callback plugin is included in the package so you should not have to copy it manually. It should get extracted in <python_prefix>/share/molecule/ansible/plugins/callback/idempotence.

You can find you Python prefix with this one liner: python -c "import sys; print(sys.prefix)". If you installed Molecule system wide, your prefix should be /usr or /usr/local/, if you used a virtualenv, it should point to the virtualenv, for instance ``~/.virtualenvs/molecule`

As a workaround, in the molecule.yml, in the raw_env_vars you can define the ANSIBLE_CALLBACK_PLUGINS environment variable to point to the location where you manually copied the plugin.

Could you run this find command and tell me where the package extracted the plugin please?
find / -name idempotence.py 2>/dev/null

@jpooler

This comment has been minimized.

jpooler commented Jan 7, 2016

find / -name idempotence.py 2>/dev/null
/Users/jarrod/.virtualenvs/molecule/share/molecule/ansible/plugins/callback/idempotence/idempotence.py
/Users/jarrod/Tools/git/molecule/assets/ansible/plugins/callback/idempotence/idempotence.py

It doesn't seem like it was extracted via the initial pip installl molecule I did. The virtualenv one looks accurate, but I'm still getting the error.

I've tried the manual override mentioned above, but just get this:

DEBUG: ANSIBLE ENVIRONMENT
ANSIBLE_CALLBACK_PLUGINS: /Users/jarrod/Tools/git/am-dec8/callback_plugins/System/Library/Frameworks/Python.framework/Versions/2.7/share/molecule/ansible/plugins/callback/idempotence
ANSIBLE_CONFIG: .molecule/ansible.cfg
ANSIBLE_FORCE_COLOR: 'false'
ANSIBLE_HOME: /Users/jarrod/Tools/git/ansible_upstream
ANSIBLE_HOST_KEY_CHECKING: 'false'

Still trying to get it working, thanks for the help!

@rgreinho

This comment has been minimized.

Contributor

rgreinho commented Jan 7, 2016

Reading your message, I tried installing molecule system wide, using pip, on Mac OS and the plugin gets extracted to /usr/local/share/molecule/ansible/plugins/callback/idempotence/idempotence.py. Besides I got the correct behaviour when running molecule test on one of my roles. So I cannot repro the problem for a system wide installation.

Your virtual environment seems correct, but your ANSIBLE_CALLBACK_PLUGINS is definitely not.
Can your try updating the ansible section this to your molecule.yml file to have it look like:

ansible:
  [...]
  raw_env_vars:
    ANSIBLE_CALLBACK_PLUGINS: /Users/jarrod/.virtualenvs/molecule/share/molecule/ansible/plugins/callback/idempotence/

And then run again molecule test. Be sure to have the virtual environment activated.

@jpooler

This comment has been minimized.

jpooler commented Jan 7, 2016

I tried prepending with the above and it still tries this:

DEBUG: ANSIBLE ENVIRONMENT
ANSIBLE_CALLBACK_PLUGINS: /Users/jarrod/.virtualenvs/molecule/share/molecule/ansible/plugins/callback/idempotence//System/Library/Frameworks/Python.framework/Versions/2.7/share/molecule/ansible/plugins/callback/idempotence

I'll try uninstalling systemwide next and see how it goes.

@rgreinho

This comment has been minimized.

Contributor

rgreinho commented Jan 7, 2016

Oh I think I see a bug. Can you try adding a colon (:) at the end of the path?

ansible:
  [...]
  raw_env_vars:
    ANSIBLE_CALLBACK_PLUGINS: /Users/jarrod/.virtualenvs/molecule/share/molecule/ansible/plugins/callback/idempotence/:
@jpooler

This comment has been minimized.

jpooler commented Jan 7, 2016

I'm getting this now:

Unexpected Exception: 'module' object has no attribute 'CallbackModule'

I had to put single quotes around it since the colon doesn't play nicely when python parses the json.

ANSIBLE_CALLBACK_PLUGINS: '/Users/jarrod/.virtualenvs/molecule/share/molecule/ansible/plugins/callback/idempotence/:'

This is where I'm at now, I'm using ansible 2.0.0 stable, but going to try and get it working on 1.9.4, I think the callback plugin you have isn't 2.0 compatible, based on my experience with the slack callback plugin and ansible 2.0 (formatting changes).

@jpooler

This comment has been minimized.

jpooler commented Jan 7, 2016

When I try this with Ansible 1.9.4, I get this:

DEBUG: ANSIBLE ENVIRONMENT
ANSIBLE_CALLBACK_PLUGINS: '/Users/jarrod/.virtualenvs/molecule/share/molecule/ansible/plugins/callback/idempotence/:'
ANSIBLE_CONFIG: .molecule/ansible.cfg
ANSIBLE_FORCE_COLOR: 'true'
ANSIBLE_HOST_KEY_CHECKING: 'false'
ANSIBLE_SSH_ARGS: -o UserKnownHostsFile=/dev/null -o IdentitiesOnly=yes -o ControlMaster=auto
-o ControlPersist=60s

DEBUG: ANSIBLE PLAYBOOK
/usr/local/bin/ansible-playbook playbook.yml --inventory-file=.molecule/ansible_inventory --vault-password-file=~/.pass --extra-vars={'datadog_api_key': '0', 'datadog_install_client': False, 'internal': '{{ansible_eth0.ipv4.address}}', 'private_interface': 'eth0', 'external': '{{ansible_eth0.ipv4.address}}'} --sudo --connection=ssh --limit=all --user=vagrant --timeout=30 --diff

ERROR: Expecting property name enclosed in double quotes: line 1 column 2 (char 1)

@rgreinho

This comment has been minimized.

Contributor

rgreinho commented Jan 7, 2016

Oh, ok, so molecule does not support ansible 2.0.0. We may think of supporting it once it will be released, but certainly not before.

Regarding the problem with 1.9.4, it looks like your extra vars should be quoted differently: http://docs.ansible.com/ansible/playbooks_variables.html#passing-variables-on-the-command-line

rgreinho added a commit to rgreinho/molecule that referenced this issue Jan 7, 2016

Fix callback_plugin path
When concatenating several paths, they must be separated using a colon
``(':')`` sign.

Fixes ansible#82

@rgreinho rgreinho closed this in #88 Jan 7, 2016

@binarytemple

This comment has been minimized.

binarytemple commented Jan 14, 2016

I know that molecule isn't yet supporting ansible 2.0, but I've been hacking testinfra (which wasn't working either with Ansible 2.0) and now have it working (issue details).
I'd like to get molecule integrated ASAP into my CI workflow. Is there an easy way to disable the idemotence test?
I've updated my molecule.yml file - but the changes seem to be ignored.

@rgreinho

This comment has been minimized.

Contributor

rgreinho commented Jan 14, 2016

There is no way to disable the idempotence test.

You can however call each test separately instead of calling molecule test:

molecule create
molecule converge
molecule verify
molecule destroy
@retr0h

This comment has been minimized.

Contributor

retr0h commented Jan 14, 2016

@binarytemple I believe you can update your molecule.yml, and change the test sequence to the following. That would impact what molecule test performs.

molecule:
  test:
    sequence:
      - destroy
      - create
      - converge
      - verify
      - destroy
@binarytemple

This comment has been minimized.

binarytemple commented Jan 14, 2016

Thanks @rgreinho!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment