community.general.maven_artifact 模块 – 从 Maven 仓库下载工件
注意
此模块是 community.general 集合(版本 10.1.0)的一部分。
如果您正在使用 ansible
包,您可能已经安装了这个集合。它不包含在 ansible-core
中。要检查它是否已安装,请运行 ansible-galaxy collection list
。
要安装它,请使用:ansible-galaxy collection install community.general
。您需要满足进一步的要求才能使用此模块,请参阅要求了解详细信息。
要在 Playbook 中使用它,请指定:community.general.maven_artifact
。
概要
从 Maven 仓库下载工件,给定提供给模块的 Maven 坐标。
可以检索工件的快照或发布版本,如果版本不可用,将解析为最新的可用版本。
要求
执行此模块的主机需要以下要求。
lxml
如果使用 S3 仓库(
s3://...
),则需要 boto
参数
参数 |
注释 |
---|---|
Maven artifactId 坐标。 |
|
结果文件系统对象应具有的属性。 要获取支持的标志,请查看目标系统上 此字符串应包含与 默认情况下假定使用 |
|
如果为 如果为 选择
|
|
Maven classifier 坐标。 默认值: |
|
PEM 格式的证书链文件,用于 SSL 客户端身份验证。 此文件也可以包含密钥,如果包含密钥,则不需要 |
|
包含您的私钥的 PEM 格式文件,用于 SSL 客户端身份验证。 如果 |
|
应将工件写入到的路径。 如果指定了文件模式或所有权,并且目标路径已存在,则它们会影响下载的文件。 |
|
文件系统权限模式,以递归方式应用于 |
|
Maven 类型/扩展坐标。 默认值: |
|
httplib2(uri 模块使用的库)仅当 Web 服务以 401 状态响应初始请求时才会发送身份验证信息。由于某些基本身份验证服务没有正确发送 401,因此登录将失败。此选项强制在初始请求时发送基本身份验证标头。 选择
|
|
应拥有文件系统对象的所有者的组的名称,就像提供给 如果未指定,它将使用当前用户的当前组,除非您是 root 用户,在这种情况下它可以保留以前的所有权。 |
|
Maven groupId 坐标。 |
|
以哈希/字典格式向请求添加自定义 HTTP 标头。 |
|
如果为 仅当 选择
|
|
结果文件系统对象应具有的权限。 对于那些习惯使用 如果未遵循这些规则中的任何一个,则给 Ansible 一个数字最终会得到一个十进制数字,这将导致意外的结果。 从 Ansible 1.8 开始,模式可以指定为符号模式(例如, 如果未指定 如果未指定 指定 |
|
应该拥有文件系统对象的用户的名称,就像提供给 如果未指定,它将使用当前用户,除非您是 root 用户,在这种情况下它可以保留之前的属主关系。 指定数字用户名将被假定为用户 ID,而不是用户名。避免使用数字用户名以避免这种混淆。 |
|
用于向 Maven 存储库进行身份验证的密码。如果存储库托管在 S3 上,请使用 AWS 秘密访问密钥。 |
|
要从中下载的 Maven 存储库的 URL。 如果存储库托管在 Amazon S3 上,请使用 如果存储库是本地的,请使用 默认: |
|
SELinux 文件系统对象上下文的级别部分。 这是 MLS/MCS 属性,有时也称为 当设置为 |
|
SELinux 文件系统对象上下文的角色部分。 当设置为 |
|
SELinux 文件系统对象上下文的类型部分。 当设置为 |
|
SELinux 文件系统对象上下文的用户部分。 默认情况下,它使用 当设置为 |
|
工件的期望状态。 选择
|
|
指定连接尝试的超时时间(以秒为单位)。 默认: |
|
一个不应包含在重定向中的标头列表。这些标头将发送到 在 ansible-core 2.12 或更高版本中,此选项的默认值为 如果重定向 URL 不需要在请求中包含敏感标头,则此选项很有用。 需要 ansible-core 2.12 或更高版本。 |
|
影响何时使用原子操作以防止数据损坏或从目标文件系统对象读取不一致的数据。 默认情况下,此模块使用原子操作来防止数据损坏或从目标文件系统对象读取不一致的数据,但有时系统的配置方式或只是以阻止此操作的方式损坏。一个例子是 docker 挂载的文件系统对象,这些对象无法从容器内部以原子方式更新,并且只能以不安全的方式写入。 此选项允许 Ansible 在原子操作失败时回退到不安全的文件系统对象更新方法(但是,它不会强制 Ansible 执行不安全的写入)。 重要提示!不安全的写入容易出现竞争条件,并可能导致数据损坏。 选择
|
|
要作为身份验证的用户,以便连接 Maven 存储库。如果存储库托管在 S3 上,请使用 AWS 秘密密钥。 |
|
如果 选择
|
|
如果为 如果为 如果为
选择
|
|
Maven 版本坐标。 与 |
|
Maven 依赖版本范围。 请参阅 https://cwiki.apache.org/confluence/display/MAVENOLD/Dependency+Mediation+and+Conflict+Resolution 上支持的版本范围 不支持范围类型 与 |
属性
属性 |
支持 |
描述 |
---|---|---|
支持: 无 |
可以在 |
|
支持: 无 |
在 diff 模式下,将返回有关已更改内容(或可能需要在 |
示例
- name: Download the latest version of the JUnit framework artifact from Maven Central
community.general.maven_artifact:
group_id: junit
artifact_id: junit
dest: /tmp/junit-latest.jar
- name: Download JUnit 4.11 from Maven Central
community.general.maven_artifact:
group_id: junit
artifact_id: junit
version: 4.11
dest: /tmp/junit-4.11.jar
- name: Download an artifact from a private repository requiring authentication
community.general.maven_artifact:
group_id: com.company
artifact_id: library-name
repository_url: 'https://repo.company.com/maven'
username: user
password: pass
dest: /tmp/library-name-latest.jar
- name: Download an artifact from a private repository requiring certificate authentication
community.general.maven_artifact:
group_id: com.company
artifact_id: library-name
repository_url: 'https://repo.company.com/maven'
client_cert: /path/to/cert.pem
client_key: /path/to/key.pem
dest: /tmp/library-name-latest.jar
- name: Download a WAR File to the Tomcat webapps directory to be deployed
community.general.maven_artifact:
group_id: com.company
artifact_id: web-app
extension: war
repository_url: 'https://repo.company.com/maven'
dest: /var/lib/tomcat7/webapps/web-app.war
- name: Keep a downloaded artifact's name, i.e. retain the version
community.general.maven_artifact:
version: latest
artifact_id: spring-core
group_id: org.springframework
dest: /tmp/
keep_name: true
- name: Download the latest version of the JUnit framework artifact from Maven local
community.general.maven_artifact:
group_id: junit
artifact_id: junit
dest: /tmp/junit-latest.jar
repository_url: "file://{{ lookup('env','HOME') }}/.m2/repository"
- name: Download the latest version between 3.8 and 4.0 (exclusive) of the JUnit framework artifact from Maven Central
community.general.maven_artifact:
group_id: junit
artifact_id: junit
version_by_spec: "[3.8,4.0)"
dest: /tmp/