maven_artifact: fix broken import (#33749)

* Fail when lxml isn't available

* whole project requires Python >= 2.6
This commit is contained in:
Pilou 2017-12-13 14:54:05 +01:00 committed by John R Barker
parent 99abe24d74
commit 02e965ba20
2 changed files with 8 additions and 3 deletions

View file

@ -28,7 +28,6 @@ description:
version if one is not available.
author: "Chris Schmidt (@chrisisbeef)"
requirements:
- "python >= 2.6"
- lxml
- boto if using a S3 repository (s3://...)
options:
@ -155,7 +154,11 @@ import os
import posixpath
import sys
from lxml import etree
try:
from lxml import etree
HAS_LXML_ETREE = True
except ImportError:
HAS_LXML_ETREE = False
try:
import boto3
@ -419,6 +422,9 @@ def main():
add_file_common_args=True
)
if not HAS_LXML_ETREE:
module.fail_json(msg='module requires the lxml python library installed on the managed machine')
repository_url = module.params["repository_url"]
if not repository_url:
repository_url = "http://repo1.maven.org/maven2"

View file

@ -32,6 +32,5 @@ lib/ansible/modules/network/lenovo/cnos_template.py
lib/ansible/modules/network/lenovo/cnos_vlag.py
lib/ansible/modules/network/lenovo/cnos_vlan.py
lib/ansible/modules/network/nxos/nxos_file_copy.py
lib/ansible/modules/packaging/language/maven_artifact.py
lib/ansible/modules/packaging/os/yum_repository.py
lib/ansible/modules/system/hostname.py