mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Fix gcp_storage_file lookup plugin (#1284).
This commit is contained in:
parent
75fd32ca55
commit
0109310aa2
2 changed files with 9 additions and 1 deletions
|
@ -2,3 +2,4 @@ bugfixes:
|
||||||
- "linode inventory plugin - make sure that plugin errors out on initialization if the required library is not found, and not on load-time (https://github.com/ansible-collections/community.general/pull/1297)."
|
- "linode inventory plugin - make sure that plugin errors out on initialization if the required library is not found, and not on load-time (https://github.com/ansible-collections/community.general/pull/1297)."
|
||||||
- "redis cache plugin - make sure that plugin errors out on initialization if the required library is not found, and not on load-time (https://github.com/ansible-collections/community.general/pull/1297)."
|
- "redis cache plugin - make sure that plugin errors out on initialization if the required library is not found, and not on load-time (https://github.com/ansible-collections/community.general/pull/1297)."
|
||||||
- "memcached cache plugin - make sure that plugin errors out on initialization if the required library is not found, and not on load-time (https://github.com/ansible-collections/community.general/pull/1297)."
|
- "memcached cache plugin - make sure that plugin errors out on initialization if the required library is not found, and not on load-time (https://github.com/ansible-collections/community.general/pull/1297)."
|
||||||
|
- "gcp_storage_files lookup plugin - make sure that plugin errors out on initialization if the required library is not found, and not on load-time (https://github.com/ansible-collections/community.general/pull/1297)."
|
||||||
|
|
|
@ -48,11 +48,16 @@ import base64
|
||||||
import json
|
import json
|
||||||
import mimetypes
|
import mimetypes
|
||||||
import os
|
import os
|
||||||
import requests
|
|
||||||
from ansible.errors import AnsibleError
|
from ansible.errors import AnsibleError
|
||||||
from ansible.plugins.lookup import LookupBase
|
from ansible.plugins.lookup import LookupBase
|
||||||
from ansible.utils.display import Display
|
from ansible.utils.display import Display
|
||||||
|
|
||||||
|
try:
|
||||||
|
import requests
|
||||||
|
HAS_REQUESTS = True
|
||||||
|
except ImportError:
|
||||||
|
HAS_REQUESTS = False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from ansible_collections.google.cloud.plugins.module_utils.gcp_utils import navigate_hash, GcpSession
|
from ansible_collections.google.cloud.plugins.module_utils.gcp_utils import navigate_hash, GcpSession
|
||||||
HAS_GOOGLE_CLOUD_COLLECTION = True
|
HAS_GOOGLE_CLOUD_COLLECTION = True
|
||||||
|
@ -146,4 +151,6 @@ class LookupModule(LookupBase):
|
||||||
def run(self, terms, variables=None, **kwargs):
|
def run(self, terms, variables=None, **kwargs):
|
||||||
if not HAS_GOOGLE_CLOUD_COLLECTION:
|
if not HAS_GOOGLE_CLOUD_COLLECTION:
|
||||||
raise AnsibleError("community.general.gcp_storage_file needs a supported version of the google.cloud collection installed")
|
raise AnsibleError("community.general.gcp_storage_file needs a supported version of the google.cloud collection installed")
|
||||||
|
if not HAS_REQUESTS:
|
||||||
|
raise AnsibleError("community.general.gcp_storage_file needs requests installed. Use `pip install requests` to install it")
|
||||||
return GcpFileLookup().run(terms, variables=variables, **kwargs)
|
return GcpFileLookup().run(terms, variables=variables, **kwargs)
|
||||||
|
|
Loading…
Reference in a new issue