From 02e965ba2059cb152f62b46b28616ad6f5ee2a94 Mon Sep 17 00:00:00 2001 From: Pilou Date: Wed, 13 Dec 2017 14:54:05 +0100 Subject: [PATCH] maven_artifact: fix broken import (#33749) * Fail when lxml isn't available * whole project requires Python >= 2.6 --- .../modules/packaging/language/maven_artifact.py | 10 ++++++++-- test/sanity/import/skip.txt | 1 - 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/ansible/modules/packaging/language/maven_artifact.py b/lib/ansible/modules/packaging/language/maven_artifact.py index e44a11a625..c1370abab5 100644 --- a/lib/ansible/modules/packaging/language/maven_artifact.py +++ b/lib/ansible/modules/packaging/language/maven_artifact.py @@ -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" diff --git a/test/sanity/import/skip.txt b/test/sanity/import/skip.txt index 8dcd1b3372..ee33e58233 100644 --- a/test/sanity/import/skip.txt +++ b/test/sanity/import/skip.txt @@ -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