ansible / molecule

Molecule aids in the development and testing of Ansible content: collections, playbooks and roles
https://ansible.readthedocs.io/projects/molecule/
MIT License
3.89k stars 665 forks source link

[v2] error resolving cookiecutter directory when installed using pip #676

Closed detiber closed 7 years ago

detiber commented 7 years ago

Issue Type

Molecule and Ansible details

ansible --version
ansible 2.2.0.0
molecule --version
molecule, version 1.14.1.dev50 (v2 branch)

Desired Behaviour

virtualenv venv
source venv/bin/activate
pip install  git+https://github.com/metacloud/molecule@v2
ansible-galaxy init test_role
cd test_role
molecule init scenario --role-name test_role --scenario-name default 

returns successfully and initializes molecule for the existing role

Actual Behaviour (Bug report only)

--> Initializing new scenario default...
Traceback (most recent call last):
  File "/home/jdetiber/git/github/openshift/v3/openshift-ansible/venv/bin/molecule", line 10, in <module>
    sys.exit(main())
  File "/home/jdetiber/git/github/openshift/v3/openshift-ansible/venv/lib/python2.7/site-packages/molecule/shell.py", line 29, in main
    cli(obj={})
  File "/home/jdetiber/git/github/openshift/v3/openshift-ansible/venv/lib/python2.7/site-packages/click/core.py", line 716, in __call__
    return self.main(*args, **kwargs)
  File "/home/jdetiber/git/github/openshift/v3/openshift-ansible/venv/lib/python2.7/site-packages/click/core.py", line 696, in main
    rv = self.invoke(ctx)
  File "/home/jdetiber/git/github/openshift/v3/openshift-ansible/venv/lib/python2.7/site-packages/click/core.py", line 1060, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/jdetiber/git/github/openshift/v3/openshift-ansible/venv/lib/python2.7/site-packages/click/core.py", line 1060, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/jdetiber/git/github/openshift/v3/openshift-ansible/venv/lib/python2.7/site-packages/click/core.py", line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/jdetiber/git/github/openshift/v3/openshift-ansible/venv/lib/python2.7/site-packages/click/core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "/home/jdetiber/git/github/openshift/v3/openshift-ansible/venv/lib/python2.7/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/jdetiber/git/github/openshift/v3/openshift-ansible/venv/lib/python2.7/site-packages/molecule/command/init.py", line 203, in scenario
    _init_new_scenario(command_args)
  File "/home/jdetiber/git/github/openshift/v3/openshift-ansible/venv/lib/python2.7/site-packages/molecule/command/init.py", line 117, in _init_new_scenario
    _process_templates(template, extra_context, scenario_base_directory)
  File "/home/jdetiber/git/github/openshift/v3/openshift-ansible/venv/lib/python2.7/site-packages/molecule/command/init.py", line 55, in _process_templates
    no_input=True, )
  File "/home/jdetiber/git/github/openshift/v3/openshift-ansible/venv/lib/python2.7/site-packages/cookiecutter/main.py", line 116, in cookiecutter
    'The repository {0} could not be located.'.format(template)
cookiecutter.exceptions.RepositoryNotFound: The repository /home/jdetiber/git/github/openshift/v3/openshift-ansible/venv/lib/python2.7/site-packages/molecule/command/../../cookiecutter/scenario/driver/docker could not be located.

With the move of the cookiecutter directory to the root of the molecule repo, it is no longer included in the molecule package, and the init command attempts to access the cookiecutter files from ../../cookiecutter, which on an installed system is the directory of the cookiecutter package in site-packages. Please give some details of what is actually happening. Include a minimum complete verifiable example with output of running molecule --debug.

retr0h commented 7 years ago

With the move of the cookiecutter directory to the root of the molecule repo, it is no longer included in the molecule package, and the init command attempts to access the cookiecutter files from ../../cookiecutter, which on an installed system is the directory of the cookiecutter package in site-packages.

This must have been an oversight on my part. I shouldn't have moved it outside the moleucle directory.

detiber commented 7 years ago

@retr0h I'll submit a PR that moves it back, working through some initial testing with v2

retr0h commented 7 years ago

Corrected by #678.