Hi there,
I’m working on a new module (cloudfront_distribution) and have started getting an error in the past week with Shippable failing.
The error is shown below:
The test ansible-test sanity --test import --python 3.6
failed with the following error:
lib/ansible/modules/cloud/amazon/cloudfront_distribution.py:539:0: ModuleNotFoundError: No module named 'ansible.modules'
The error is occurring because I am importing another module (cloudfront_facts) into this module, specifically the line:
from ansible.modules.cloud.amazon.cloudfront_facts import CloudFrontFactsServiceManager
I could copy all the methods from cloudfront_facts into the cloudfront_distribution module, but my concern with this is twofold:
- There are 18 calls to cloudfront_facts from cloudfront_distribution - albeit some calls are to the same functions, but this is still a significant amount of code to be copying verbatim into a second module.
- Adding the duplicate code would also lead to unnecessary code bloat and maintenance, and goes against the DRY coding principle (Don’t Repeat Yourself).
I was wondering if there is a way to prevent this Shippable error without duplicating the code between modules. Is there possibly a file the module can be added to to skip this Shippable test?
There is probably a perfectly valid reason for this test to fail (such as preventing dependency chains) and there may be another alternative, (like placing the common code into module_utils/aws or module_utils/facts), but thought I’d open it up for discussion on the best way to approach/fix this.
Thanks,
Will