mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-24 05:40:23 -07:00
gcp_storage_file: error gracefully when google.cloud is not there (#372)
* Error gracefully when google.cloud is not there. * Add changelog fragment.
This commit is contained in:
parent
b52a6010b6
commit
72fe304b8f
2 changed files with 10 additions and 1 deletions
|
@ -48,7 +48,12 @@ import requests
|
|||
from ansible.errors import AnsibleError
|
||||
from ansible.plugins.lookup import LookupBase
|
||||
from ansible.utils.display import Display
|
||||
from ansible_collections.google.cloud.plugins.module_utils.gcp_utils import navigate_hash, GcpSession
|
||||
|
||||
try:
|
||||
from ansible_collections.google.cloud.plugins.module_utils.gcp_utils import navigate_hash, GcpSession
|
||||
HAS_GOOGLE_CLOUD_COLLECTION = True
|
||||
except ImportError:
|
||||
HAS_GOOGLE_CLOUD_COLLECTION = False
|
||||
|
||||
|
||||
display = Display()
|
||||
|
@ -135,4 +140,6 @@ class GcpFileLookup():
|
|||
|
||||
class LookupModule(LookupBase):
|
||||
def run(self, terms, variables=None, **kwargs):
|
||||
if not HAS_GOOGLE_CLOUD_COLLECTION:
|
||||
raise AnsibleError("community.general.gcp_storage_files needs a supported version of the google.cloud collection installed")
|
||||
return GcpFileLookup().run(terms, variables=variables, **kwargs)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue