Skip to content

Commit

Permalink
Type options of cache plugins (#8624)
Browse files Browse the repository at this point in the history
* Type options of cache plugins.

* Do not change type of _timeout for now.
  • Loading branch information
felixfontein authored Jul 28, 2024
1 parent 1a8f172 commit 37c8560
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 2 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/8624-cache-types.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- "memcached, pickle, redis, yaml cache plugins - make sure that all options are typed (https://github.com/ansible-collections/community.general/pull/8624)."
4 changes: 3 additions & 1 deletion plugins/cache/memcached.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
section: defaults
_prefix:
description: User defined prefix to use when creating the DB entries
type: string
default: ansible_facts
env:
- name: ANSIBLE_CACHE_PLUGIN_PREFIX
Expand All @@ -37,13 +38,14 @@
section: defaults
_timeout:
default: 86400
type: integer
# TODO: determine whether it is OK to change to: type: float
description: Expiration timeout in seconds for the cache plugin data. Set to 0 to never expire
env:
- name: ANSIBLE_CACHE_PLUGIN_TIMEOUT
ini:
- key: fact_caching_timeout
section: defaults
type: integer
'''

import collections
Expand Down
3 changes: 3 additions & 0 deletions plugins/cache/pickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@
ini:
- key: fact_caching_connection
section: defaults
type: path
_prefix:
description: User defined prefix to use when creating the files
env:
- name: ANSIBLE_CACHE_PLUGIN_PREFIX
ini:
- key: fact_caching_prefix
section: defaults
type: string
_timeout:
default: 86400
description: Expiration timeout in seconds for the cache plugin data. Set to 0 to never expire
Expand All @@ -39,6 +41,7 @@
ini:
- key: fact_caching_timeout
section: defaults
type: float
'''

try:
Expand Down
7 changes: 6 additions & 1 deletion plugins/cache/redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
- The format is V(host:port:db:password), for example V(localhost:6379:0:changeme).
- To use encryption in transit, prefix the connection with V(tls://), as in V(tls://localhost:6379:0:changeme).
- To use redis sentinel, use separator V(;), for example V(localhost:26379;localhost:26379;0:changeme). Requires redis>=2.9.0.
type: string
required: true
env:
- name: ANSIBLE_CACHE_PLUGIN_CONNECTION
Expand All @@ -29,6 +30,7 @@
section: defaults
_prefix:
description: User defined prefix to use when creating the DB entries
type: string
default: ansible_facts
env:
- name: ANSIBLE_CACHE_PLUGIN_PREFIX
Expand All @@ -37,6 +39,7 @@
section: defaults
_keyset_name:
description: User defined name for cache keyset name.
type: string
default: ansible_cache_keys
env:
- name: ANSIBLE_CACHE_REDIS_KEYSET_NAME
Expand All @@ -46,6 +49,7 @@
version_added: 1.3.0
_sentinel_service_name:
description: The redis sentinel service name (or referenced as cluster name).
type: string
env:
- name: ANSIBLE_CACHE_REDIS_SENTINEL
ini:
Expand All @@ -54,13 +58,14 @@
version_added: 1.3.0
_timeout:
default: 86400
type: integer
# TODO: determine whether it is OK to change to: type: float
description: Expiration timeout in seconds for the cache plugin data. Set to 0 to never expire
env:
- name: ANSIBLE_CACHE_PLUGIN_TIMEOUT
ini:
- key: fact_caching_timeout
section: defaults
type: integer
'''

import re
Expand Down
3 changes: 3 additions & 0 deletions plugins/cache/yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@
ini:
- key: fact_caching_connection
section: defaults
type: string
_prefix:
description: User defined prefix to use when creating the files
env:
- name: ANSIBLE_CACHE_PLUGIN_PREFIX
ini:
- key: fact_caching_prefix
section: defaults
type: string
_timeout:
default: 86400
description: Expiration timeout in seconds for the cache plugin data. Set to 0 to never expire
Expand All @@ -40,6 +42,7 @@
- key: fact_caching_timeout
section: defaults
type: integer
# TODO: determine whether it is OK to change to: type: float
'''


Expand Down

0 comments on commit 37c8560

Please sign in to comment.