ansible / ansible-modules-extras

Ansible extra modules - these modules ship with ansible
948 stars 1.46k forks source link

maven_artifact does not use classifier when constructing destination name of artifact #2139

Closed tmoschou closed 7 years ago

tmoschou commented 8 years ago
ISSUE TYPE

maven_artifact

ANSIBLE VERSION
$ ansible --version
ansible 2.2.0 (devel 1fc44e4103) last updated 2016/05/02 13:44:52 (GMT +1050)
  lib/ansible/modules/core: (detached HEAD b6ad3b6773) last updated 2016/05/02 13:45:21 (GMT +1050)
  lib/ansible/modules/extras: (devel 1846de2809) last updated 2016/05/02 13:28:20 (GMT +1050)
  config file = xxx/ansible-playbooks/ansible.cfg
  configured module search path = Default w/o overrides
CONFIGURATION
[defaults]
host_key_checking = False
[ssh_connection]
control_path = %(directory)s/%%h-%%r
OS / ENVIRONMENT

OS X El Capitan v10.11.4

SUMMARY

When specifying a classifier for maven_artifact and a directory as the dest parameter, the destination filename is constructed assuming no classifier. I.e.

artifact_id + "-" + version + "." + extension vs artifact_id + "-" + version + "-" + classifier + "." + extension

This causes problems when say downloading multiple artifacts with same same groupId:artifactId:version coordinates. Depending of the version of lib/ansible/modules/extras used, either subsequent artifacts are skipped because the destination exists, or is overwritten as the MD5 hash is different.

STEPS TO REPRODUCE

---
- hosts: test-hosts
  tasks:
    - name: Create temporary directory
      file:
        path: /tmp/ansible-test
        state: directory

    - name: Download Stanford Core NLP
      maven_artifact:
        group_id: edu.stanford.nlp
        artifact_id: stanford-corenlp
        version: 3.6.0
        dest: /tmp/ansible-test/
        state: present

    - name: Download Stanford Core NLP Models
      maven_artifact:
        group_id: edu.stanford.nlp
        artifact_id: stanford-corenlp
        version: 3.6.0
        classifier: models
        dest: /tmp/ansible-test/
        state: present
EXPECTED RESULTS

Should download two artifacts to

/tmp/ansible-test/stanford-corenlp-3.6.0.jar, and
/tmp/ansible-test/stanford-corenlp-3.6.0-models.jar
ACTUAL RESULTS

One file /tmp/ansible-test/stanford-corenlp-3.6.0.jar

alikins commented 8 years ago

Looks like https://github.com/ansible/ansible-modules-extras/blob/devel/packaging/language/maven_artifact.py#L335 is the likely culprit. The destination dir name building may make more sense to move into MavenArtifact() class.

ansibot commented 8 years ago

@chrisisbeef, ping. This issue is still waiting on your response. click here for bot help

ansibot commented 8 years ago

@chrisisbeef, ping. This issue is still waiting on your response. click here for bot help

chrisisbeef commented 8 years ago

@tmoschou / @alikins - I'll take a look at this today

abaschen commented 8 years ago

@chrisisbeef I have also the issue and found at line 214 that we go check the latest build number regardless of the classifier. I have 2 classifier A and B which have build numbers 79 and 80. If I want to download the snapshot for A it will give the build version of B because it's the latest. I will try to fix it and make a pull request.

edit: done Pull request posted

ansibot commented 8 years ago

@chrisisbeef, ping. This issue is still waiting on your response. click here for bot help

ansibot commented 8 years ago

@chrisisbeef, ping. This issue is still waiting on your response. click here for bot help

ansibot commented 8 years ago

@chrisisbeef, ping. This issue is still waiting on your response. click here for bot help

abaschen commented 8 years ago

Apparently this https://github.com/ansible/ansible-modules-extras/commit/1db36bea62d032f841153f2abd04d84fceb48fa7 fixes the issue. consider review for closing

bdellegrazie commented 7 years ago

No 1db36be doesn't fix the issue for a non snapshot version with classifier

ansibot commented 7 years ago

@chrisisbeef, ping. This issue is still waiting on your response. click here for bot help

ansibot commented 7 years ago

This repository has been locked. All new issues and pullrequests should be filed in https://github.com/ansible/ansible

Please read through the repomerge page in the dev guide. The guide contains links to tools which automatically move your issue or pullrequest to the ansible/ansible repo.

webvictim commented 7 years ago

This issue was moved to ansible/ansible#24724