ansible / mazer

Experimental Ansible Galaxy Content Manager
GNU General Public License v3.0
114 stars 18 forks source link

AttributeError: 'RequirementSpec' object has no attribute 'scm' #236

Closed lorien closed 5 years ago

lorien commented 5 years ago

Bug Report

MAZER VERSION
name = mazer
version = 0.4.0
config_file = /home/lorien/.ansible/mazer.yml
uname = Linux, air, 4.19.0-0.bpo.2-amd64, #1 SMP Debian 4.19.16-1~bpo9+1 (2019-02-07), x86_64
executable_location = /usr/local/bin/mazer
python_version = 2.7.13 (default, Jan 19 2017, 14:48:08) [GCC 6.3.0 20170118]
python_executable = /usr/bin/python2

Ansible:

ansible 2.8.0rc2
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/lorien/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python2.7/dist-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 2.7.13 (default, Jan 19 2017, 14:48:08) [GCC 6.3.0 20170118]
CONFIGURATION

default

SUMMARY

Fail to install role from github.

STEPS TO REPRODUCE
mazer install --namespace geerlingguy git+https://github.com/geerlingguy/ansible-role-nginx
EXPECTED RESULTS

Expect to not get an error

ACTUAL RESULTS

Error:

$ mazer install --namespace geerlingguy git+https://github.com/geerlingguy/ansible-role-nginx
Installing geerlingguy.ansible-role-nginx
RequirementSpec(namespace='geerlingguy', name='ansible-role-nginx', version_spec=<Spec: (<SpecItem: * u''>,)>, version_aka=None, fetch_method='SCM_URL', src='https://github.com/geerlingguy/ansible-role-nginx', req_spec_string=None)
'RequirementSpec' object has no attribute 'scm'
Traceback (most recent call last):
  File "/usr/local/bin/mazer", line 10, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/dist-packages/ansible_galaxy_cli/main.py", line 35, in main
    exit_code = cli.run()
  File "/usr/local/lib/python2.7/dist-packages/ansible_galaxy_cli/cli/galaxy.py", line 231, in run
    return self.execute()
  File "/usr/local/lib/python2.7/dist-packages/ansible_galaxy_cli/cli/__init__.py", line 152, in execute
    return fn()
  File "/usr/local/lib/python2.7/dist-packages/ansible_galaxy_cli/cli/galaxy.py", line 295, in execute_install
    force_overwrite=self.options.force)
  File "/usr/local/lib/python2.7/dist-packages/ansible_galaxy/actions/install.py", line 149, in install_repository_specs_loop
    force_overwrite=force_overwrite)
  File "/usr/local/lib/python2.7/dist-packages/ansible_galaxy/actions/install.py", line 88, in install_repositories_matching_repository_specs
    force_overwrite=force_overwrite)
  File "/usr/local/lib/python2.7/dist-packages/ansible_galaxy/actions/install.py", line 259, in install_repositories
    force_overwrite=force_overwrite)
  File "/usr/local/lib/python2.7/dist-packages/ansible_galaxy/actions/install.py", line 378, in install_repository
    find_results=find_results)
  File "/usr/local/lib/python2.7/dist-packages/ansible_galaxy/install.py", line 44, in fetch
    fetch_results = fetcher.fetch(find_results=find_results)
  File "/usr/local/lib/python2.7/dist-packages/ansible_galaxy/fetch/scm_url.py", line 34, in fetch
    scm=self.requirement_spec.scm,
AttributeError: 'RequirementSpec' object has no attribute 'scm'
alikins commented 5 years ago

@lorien

The current version of mazer doesn't support install traditional roles (like geerlingguy/ansible-role-nginx) directly anymore. Mazer now only supports install of 'collections' (unlike ansible-galaxy), though using scm urls for collections is also broken at the moment.

'direct install of traditional roles' meaning things like this aren't expected to work

But install of collections from galaxy is supported (though not from production galaxy.ansible.com quite yet) and meant to work:

'alikins-collection_ntp-1.2.3.tar.gz' is the collection 'artifact' built as result of running 'mazer build' in a checkout of https://github.com/alikins/collection_ntp

At the moment, collection installs from an scm_url don't quite work correctly either. They hit essentially the sane bug (and similar traceback) as you report, though I have a fix pending for that particular error.

I'm working on getting scm url installs of collections working again, but the scm url and install code paths need some changes to deal with the way scm urls aren't necessarily versioned. For example, if 'git+https://github.com/alikins/my_collection' was installed to satisfy a requirement for 'alikins.my_collection >= 2.0.0', https://github.com/alikins/my_collection may not have any versioning info, so it's hard to tell if the 'requirement' was solved.

The traceback is definitely a bug, but for that usage there will still be an error since 'ansible-role-nginx' is a role and not a 'collection', and mazer now only supports installing collections (but that is also broken at moment)

alikins commented 5 years ago

Between role install being not supported in mazer, and the scm url related fixes for #236 that should prevent the error this bug described, I'm considering this closed.

Fixed by: https://github.com/ansible/mazer/pull/241