Sometimes one specific item in a list needs special treatment or should be used in a different way.
In ansible, one method would be to use the 'selectattr()' filter which basically works like a if statement in python looking for a specific attribute value.
Here's a code snippet using selectattr to download one specific artifact from a list of artifacts
- name: download newest specific artifact
loop: "{{ application_artifacts | selectattr('artifact', 'match', application1) | list }}"
maven_artifact:
group_id: "{{ item.group }}"
artifact_id: "{{ item.artifact }}"
classifier: "{{ item.classifier }}"
extensions: "{{ item.extensions }}"
version. "{{ item.version }}"
repository_url: "{{ item.repourl }}"
dest: /tmp/
validate_certs: false
tags:
- deploy_artifacts
- deploy_application
The advantage here would be that each server will only be deployed with the artifact it would need while still maintaining a centralized list with the application's specific versions.
Feel free to comment and / or suggest a topic.
Comments
Post a Comment