community / community.general / 8.5.0 / module / redis_data_incr Increment keys in Redis | "added in version" 4.0.0 of community.general" Authors: Andreas Botzner (@paginabianca)community.general.redis_data_incr (8.5.0) — module
Install with ansible-galaxy collection install community.general:==8.5.0
collections: - name: community.general version: 8.5.0
Increment integers or float keys in Redis database and get new value.
Default increment for all keys is 1. For specific increments use the O(increment_int) and O(increment_float) options.
- 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'
key: description: - Database key. required: true type: str tls: default: true description: - Specify whether or not to use TLS for the connection. type: bool ca_certs: description: - Path to root certificates file. If not set and O(tls) is set to V(true), certifi ca-certificates will be used. type: str login_host: default: localhost description: - Specify the target host running the database. type: str login_port: default: 6379 description: - Specify the port to connect to. type: int login_user: description: - Specify the user to authenticate with. - Requires L(redis,https://pypi.org/project/redis) >= 3.4.0. type: str increment_int: description: - Integer amount to increment the key by. required: false type: int login_password: description: - Specify the password to authenticate with. - Usually not used when target is localhost. type: str validate_certs: default: true description: - Specify whether or not to validate TLS certificates. - This should only be turned off for personally controlled sites or with C(localhost) as target. type: bool increment_float: description: - Float amount to increment the key by. - This only works with keys that contain float values in their string representation. required: false type: float
msg: description: A short message. returned: always sample: 'Incremented key: foo by 20.4 to 65.9' type: str value: description: Incremented value of key returned: on success sample: '4039.4' type: float