maven_artifact – Downloads an Artifact from a Maven Repository
maven_artifact – Downloads an Artifact from a Maven Repository
Synopsis
- Downloads an artifact from a maven repository given the maven coordinates provided to the module.
- Can retrieve snapshots or release versions of the artifact and will resolve the latest available version if one is not available.
Requirements
The below requirements are needed on the host that executes this module.
- lxml
- boto if using a S3 repository (s3://…)
Parameters
Parameter | Choices/Defaults | Comments |
---|---|---|
artifact_id - / required |
The maven artifactId coordinate | |
attributes string |
The attributes the resulting file or directory should have. To get supported flags look at the man page for chattr on the target system. This string should contain the attributes in the same order as the one displayed by lsattr. The
| |
classifier - |
The maven classifier coordinate | |
dest - / required |
The path where the artifact should be written to If file mode or ownerships are specified and destination path already exists, they affect the downloaded file | |
extension - |
Default: "jar" |
The maven type/extension coordinate |
group string |
Name of the group that should own the file/directory, as would be fed to chown. | |
group_id - / required |
The Maven groupId coordinate | |
headers dictionary added in 2.8 |
Add custom HTTP headers to a request in hash/dict format. | |
keep_name boolean added in 2.4 |
|
If This option only has effect when |
mode string |
The permissions the resulting file or directory should have. For those used to /usr/bin/chmod remember that modes are actually octal numbers. You must either add a leading zero so that Ansible's YAML parser knows it is an octal number (like Giving Ansible a number without following one of these rules will end up with a decimal number which will have unexpected results. As of Ansible 1.8, the mode may be specified as a symbolic mode (for example, | |
owner string |
Name of the user that should own the file/directory, as would be fed to chown. | |
password - |
The password to authenticate with to the Maven Repository. Use AWS secret access key of the repository is hosted on S3
| |
repository_url - |
Default: |
The URL of the Maven Repository to download from. Use s3://... if the repository is hosted on Amazon S3, added in version 2.2. Use file://... if the repository is local, added in version 2.6 |
selevel string |
Default: "s0" |
The level part of the SELinux file context. This is the MLS/MCS attribute, sometimes known as the When set to |
serole string |
The role part of the SELinux file context. When set to | |
setype string |
The type part of the SELinux file context. When set to | |
seuser string |
The user part of the SELinux file context. By default it uses the When set to | |
state - |
|
The desired state of the artifact |
timeout - |
Default: 10 |
Specifies a timeout in seconds for the connection attempt |
unsafe_writes boolean |
|
Influence when to use atomic operation to prevent data corruption or inconsistent reads from the target file. By default this module uses atomic operations to prevent data corruption or inconsistent reads from the target files, but sometimes systems are configured or just broken in ways that prevent this. One example is docker mounted files, which cannot be updated atomically from inside the container and can only be written in an unsafe manner. This option allows Ansible to fall back to unsafe methods of updating files when atomic operations fail (however, it doesn't force Ansible to perform unsafe writes). IMPORTANT! Unsafe writes are subject to race conditions and can lead to data corruption. |
username - |
The username to authenticate as to the Maven Repository. Use AWS secret key of the repository is hosted on S3
| |
validate_certs boolean |
|
If |
verify_checksum - added in 2.6 |
|
If If If
|
version - |
Default: "latest" |
The maven version coordinate |
Examples
# Download the latest version of the JUnit framework artifact from Maven Central
- maven_artifact:
group_id: junit
artifact_id: junit
dest: /tmp/junit-latest.jar
# Download JUnit 4.11 from Maven Central
- maven_artifact:
group_id: junit
artifact_id: junit
version: 4.11
dest: /tmp/junit-4.11.jar
# Download an artifact from a private repository requiring authentication
- 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
# Download a WAR File to the Tomcat webapps directory to be deployed
- 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
# Keep a downloaded artifact's name, i.e. retain the version
- maven_artifact:
version: latest
artifact_id: spring-core
group_id: org.springframework
dest: /tmp/
keep_name: yes
# Download the latest version of the JUnit framework artifact from Maven local
- maven_artifact:
group_id: junit
artifact_id: junit
dest: /tmp/junit-latest.jar
repository_url: "file://{{ lookup('env','HOME') }}/.m2/repository"
Status
- This module is not guaranteed to have a backwards compatible interface. [preview]
- This module is maintained by the Ansible Community. [community]
Authors
- Chris Schmidt (@chrisisbeef)
© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.9/modules/maven_artifact_module.html