From a2243d91d2da2968c0d4a24770f20d2a3077ae34 Mon Sep 17 00:00:00 2001 From: John Westcott IV Date: Thu, 21 May 2020 09:15:06 -0400 Subject: [PATCH] Now actually checking the version instead of just getting it --- awx_collection/plugins/lookup/tower_schedule_rrule.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/awx_collection/plugins/lookup/tower_schedule_rrule.py b/awx_collection/plugins/lookup/tower_schedule_rrule.py index f9fecf0289..e34751d9ac 100644 --- a/awx_collection/plugins/lookup/tower_schedule_rrule.py +++ b/awx_collection/plugins/lookup/tower_schedule_rrule.py @@ -10,7 +10,7 @@ DOCUMENTATION = """ short_description: Generate an rrule string which can be used for Tower Schedules requirements: - pytz - - python.dateutil >= 2.8.1 + - python.dateutil >= 2.7.0 description: - Returns a string based on criteria which represent an rule options: @@ -89,6 +89,7 @@ from ansible.plugins.lookup import LookupBase from ansible.errors import AnsibleError from datetime import datetime import re +from distutils.version import LooseVersion missing_modules = [] try: @@ -104,9 +105,10 @@ except ImportError: # Validate the version of python.dateutil try: import dateutil - dateutil.__version__ + if LooseVersion(dateutil.__version__) < LooseVersion("2.7.0"): + raise Exception except Exception: - missing_modules.append('python.dateutil>=2.8.1') + missing_modules.append('python.dateutil>=2.7.0') if len(missing_modules) > 0: raise AnsibleError('You are missing the modules {0}'.format(', '.join(missing_modules)))