【问题标题】:How to download specific version of war file from nexus using Ansible如何使用 Ansible 从 nexus 下载特定版本的 war 文件
【发布时间】:2020-06-22 15:14:52
【问题描述】:

我的 Nexus 存储库中存在不同版本的 war 文件。

下面是我的ansible代码

---
- hosts: localhost
  become: True
  tasks:
    - name: Download war file
      maven_artifact:
        group_id: in.flex
        artifact_id: halosys
        repository_url: 'http://34.239.122.5:8081/repository/halosys-release/'
        username: admin
        password: xxxxx
        dest: /tmp/

请告诉我在 Ansible 中下载特定版本的 war 文件的语法,例如 halosys-1.0.war, halosys-5.0.war

【问题讨论】:

  • 如果有groupId和artifact的参数,是不是也有version的参数?
  • 如何更改我的 Ansible 代码以下载特定版本的 war 文件?
  • 这是对我问题的回答吗?
  • 不,我想请提供我的 ansible 代码来满足我的要求
  • 但是您已经在问题本身中提出了这个问题。有没有检查过有没有version参数?

标签: maven ansible nexus


【解决方案1】:
- name: "Download war file"
  maven_artifact:
    group_id: in.flex
    artifact_id: halosys
    extension: war
    version: 5.0
    repository_url: "http://34.239.122.5:8081/repository/halosys-release/"
    username: admin
    password: xxxxx
    dest: "/tmp/ROOT.war"
    mode: '0644'

来源:https://docs.ansible.com/ansible/latest/modules/maven_artifact_module.html#examples

最好有vars文件并使用jinja

例子

...
version: "{{ versions.halosys }}"
...

【讨论】:

  • 小心使用version: 5.0,因为 yaml 会将其强制转换为浮点数;理想情况下,就像您对 jinja2 后续示例所做的那样引用它
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-06-28
  • 1970-01-01
  • 1970-01-01
  • 2021-07-01
  • 2020-01-22
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多