community.general.redis_data_incr module – Increment keys in Redis
Note
This module is part of the community.general collection (version 4.8.3).
You might already have this collection installed if you are using the ansible
package.
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install community.general
.
To use it in a playbook, specify: community.general.redis_data_incr
.
New in version 4.0.0: of community.general
Synopsis
Increment integers or float keys in Redis database and get new value.
Default increment for all keys is 1. For specific increments use the increment_int and increment_float options.
When using check_mode the module will try to calculate the value that Redis would return. If the key is not present, 0.0 is used as value.
Requirements
The below requirements are needed on the host that executes this module.
redis
certifi
Parameters
Parameter |
Comments |
---|---|
Path to root certificates file. If not set and tls is set to |
|
Float amount to increment the key by. This only works with keys that contain float values in their string representation. |
|
Integer amount to increment the key by. |
|
Database key. |
|
Specify the target host running the database. Default: “localhost” |
|
Specify the password to authenticate with. Usually not used when target is localhost. |
|
Specify the port to connect to. Default: 6379 |
|
Specify the user to authenticate with. Requires redis >= 3.4.0. |
|
Specify whether or not to use TLS for the connection. Choices:
|
|
Specify whether or not to validate TLS certificates. This should only be turned off for personally controlled sites or with Choices:
|
Notes
Note
For
check_mode
to work, the specified redis_user needs permission to run theGET
command on the key, otherwise the module will fail.Requires the
redis
Python package on the remote host. You can install it with pip (pip install redis
) or with a package manager. Information on the library can be found at https://github.com/andymccurdy/redis-py.
See Also
See also
- community.general.redis_data
The official documentation on the community.general.redis_data module.
- community.general.redis_data_info
The official documentation on the community.general.redis_data_info module.
- community.general.redis
The official documentation on the community.general.redis module.
Examples
- name: Increment integer key foo on localhost with no username and print new value
community.general.redis_data_incr:
login_host: localhost
login_password: supersecret
key: foo
increment_int: 1
register: result
- name: Print new value
debug:
var: result.value
- name: Increment float key foo by 20.4
community.general.redis_data_incr:
login_host: redishost
login_user: redisuser
login_password: somepass
key: foo
increment_float: '20.4'
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
A short message. Returned: always Sample: “Incremented key: foo by 20.4 to 65.9” |
|
Incremented value of key Returned: on success Sample: “4039.4” |
Authors
Andreas Botzner (@paginabianca)
Collection links
Issue Tracker Repository (Sources) Submit a bug report Request a feature Communication