mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
This commit is contained in:
parent
07fa7ea409
commit
75fd32ca55
4 changed files with 19 additions and 3 deletions
4
changelogs/fragments/fix-plugin-imports.yml
Normal file
4
changelogs/fragments/fix-plugin-imports.yml
Normal file
|
@ -0,0 +1,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)."
|
||||||
|
- "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)."
|
6
plugins/cache/memcached.py
vendored
6
plugins/cache/memcached.py
vendored
|
@ -57,8 +57,9 @@ from ansible.utils.display import Display
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import memcache
|
import memcache
|
||||||
|
HAS_MEMCACHE = True
|
||||||
except ImportError:
|
except ImportError:
|
||||||
raise AnsibleError("python-memcached is required for the memcached fact cache")
|
HAS_MEMCACHE = False
|
||||||
|
|
||||||
display = Display()
|
display = Display()
|
||||||
|
|
||||||
|
@ -187,6 +188,9 @@ class CacheModule(BaseCacheModule):
|
||||||
self._timeout = C.CACHE_PLUGIN_TIMEOUT
|
self._timeout = C.CACHE_PLUGIN_TIMEOUT
|
||||||
self._prefix = C.CACHE_PLUGIN_PREFIX
|
self._prefix = C.CACHE_PLUGIN_PREFIX
|
||||||
|
|
||||||
|
if not HAS_MEMCACHE:
|
||||||
|
raise AnsibleError("python-memcached is required for the memcached fact cache")
|
||||||
|
|
||||||
self._cache = {}
|
self._cache = {}
|
||||||
self._db = ProxyClientPool(connection, debug=0)
|
self._db = ProxyClientPool(connection, debug=0)
|
||||||
self._keys = CacheModuleKeys(self._db, self._db.get(CacheModuleKeys.PREFIX) or [])
|
self._keys = CacheModuleKeys(self._db, self._db.get(CacheModuleKeys.PREFIX) or [])
|
||||||
|
|
6
plugins/cache/redis.py
vendored
6
plugins/cache/redis.py
vendored
|
@ -73,8 +73,9 @@ from ansible.utils.display import Display
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from redis import StrictRedis, VERSION
|
from redis import StrictRedis, VERSION
|
||||||
|
HAS_REDIS = True
|
||||||
except ImportError:
|
except ImportError:
|
||||||
raise AnsibleError("The 'redis' python module (version 2.4.5 or newer) is required for the redis fact cache, 'pip install redis'")
|
HAS_REDIS = False
|
||||||
|
|
||||||
display = Display()
|
display = Display()
|
||||||
|
|
||||||
|
@ -111,6 +112,9 @@ class CacheModule(BaseCacheModule):
|
||||||
self._prefix = C.CACHE_PLUGIN_PREFIX
|
self._prefix = C.CACHE_PLUGIN_PREFIX
|
||||||
self._keys_set = 'ansible_cache_keys'
|
self._keys_set = 'ansible_cache_keys'
|
||||||
|
|
||||||
|
if not HAS_REDIS:
|
||||||
|
raise AnsibleError("The 'redis' python module (version 2.4.5 or newer) is required for the redis fact cache, 'pip install redis'")
|
||||||
|
|
||||||
self._cache = {}
|
self._cache = {}
|
||||||
kw = {}
|
kw = {}
|
||||||
|
|
||||||
|
|
|
@ -63,8 +63,9 @@ from ansible.plugins.inventory import BaseInventoryPlugin
|
||||||
try:
|
try:
|
||||||
from linode_api4 import LinodeClient
|
from linode_api4 import LinodeClient
|
||||||
from linode_api4.errors import ApiError as LinodeApiError
|
from linode_api4.errors import ApiError as LinodeApiError
|
||||||
|
HAS_LINODE = True
|
||||||
except ImportError:
|
except ImportError:
|
||||||
raise AnsibleError('the Linode dynamic inventory plugin requires linode_api4.')
|
HAS_LINODE = False
|
||||||
|
|
||||||
|
|
||||||
class InventoryModule(BaseInventoryPlugin):
|
class InventoryModule(BaseInventoryPlugin):
|
||||||
|
@ -194,6 +195,9 @@ class InventoryModule(BaseInventoryPlugin):
|
||||||
"""Dynamically parse Linode the cloud inventory."""
|
"""Dynamically parse Linode the cloud inventory."""
|
||||||
super(InventoryModule, self).parse(inventory, loader, path)
|
super(InventoryModule, self).parse(inventory, loader, path)
|
||||||
|
|
||||||
|
if not HAS_LINODE:
|
||||||
|
raise AnsibleError('the Linode dynamic inventory plugin requires linode_api4.')
|
||||||
|
|
||||||
config_data = self._read_config_data(path)
|
config_data = self._read_config_data(path)
|
||||||
self._build_client()
|
self._build_client()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue