ansible-redis
ansible-redis copied to clipboard
Setting `redis_port` other than 6379 with variable results in an error
Using ansible 2.2.1.0.
While the following playbook works,
- name: Redis master
hosts: redis-master
vars:
redis_port: 6389
roles:
- role: DavidWittman.redis
the next one results in an error, saying ERROR! The requested handler 'restart redis 6389' was not found in either the main handlers list nor in the listening handlers list while executing the create redis config file task.
- name: Redis master
hosts: redis-master
vars:
redis_port: "{{ redis_master_port }}" # redis_master_port is set to be 6389 in group_vars
roles:
- role: DavidWittman.redis
Also note that the second playbook succeeds if the redis_master_port variable is set to be 6379.
Any idea?
That's... strange. This seems like an Ansible bug. I was able to reproduce it on all the versions which this role supports. I'll have to find some time to look more closely at this unless you've since found a resolution.
I ran into a similar issue where the redis_sentinel boolean set in the playbook's vars section wasn't being picked up by the DavidWittman.redis role.
I also tried moving any variables from group_vars or host_vars directly into the role similar to this:
- { role: Community/DavidWittman.redis, redis_sentinel: true, redis_sentinel_port: 26379 }
I downgraded from Ansible 2.2.1.0 to 2.1.4.0 as a workaround.
Also running into this error. When I specify the variable as part of the role item, it fails even when the port is 6379:
- name: Redis master
hosts: redis-master
roles:
- role: DavidWittman.redis
redis_port: "{{ redis_master_port }}"
I've managed to get rid of the error when I changed handlers/main.yml file from this:
---
- name: "restart redis {{ redis_port }}"
service:
name: "{{ redis_service_name }}"
state: restarted
when: redis_as_service
to:
---
- name: "restart redis {{ redis_port }}"
service:
name: redis_{{ redis_port }}
state: restarted
when: redis_as_service
Was having RUNNING HANDLER [DavidWittman.redis : restart redis {{ redis_port }}] ********** fatal: [192.168.33.10]: FAILED! => {"changed": false, "failed": true, "msg": "Unable to restart service redis_6379: Failed to restart redis_6379.service: Interactive authentication required.\nSee system logs and 'systemctl status redis_6379.service' for details.\n"}
and I got rid of the error by making the change as suggested above.