ansible-redis icon indicating copy to clipboard operation
ansible-redis copied to clipboard

Setting `redis_port` other than 6379 with variable results in an error

Open kimamula opened this issue 8 years ago • 5 comments

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?

kimamula avatar Feb 22 '17 06:02 kimamula

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.

DavidWittman avatar Mar 09 '17 00:03 DavidWittman

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.

oolongtea avatar Mar 20 '17 18:03 oolongtea

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 }}"

brad avatar Apr 17 '17 23:04 brad

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

dsemba avatar May 17 '17 15:05 dsemba

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.

nikathone avatar Apr 07 '18 03:04 nikathone