Skip to content

Fix handlers definitions #231

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ language: python
python: "2.7"

env:
- ANSIBLE_VERSION=2.1.6
- ANSIBLE_VERSION=2.3.3
- ANSIBLE_VERSION=2.4.0
- ANSIBLE_VERSION=latest

before_install:
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

[![Build Status](https://travis-ci.org/DavidWittman/ansible-redis.svg?branch=master)](https://travis-ci.org/DavidWittman/ansible-redis) [![Ansible Galaxy](https://img.shields.io/badge/galaxy-DavidWittman.redis-blue.svg?style=flat)](https://galaxy.ansible.com/davidwittman/redis)

- Ansible 2.1+
- Ansible 2.4+
- Compatible with most versions of Ubuntu/Debian and RHEL/CentOS 6.x

## Contents

1. [Installation](#installation)
Expand Down Expand Up @@ -145,6 +145,10 @@ This will configure the Sentinel nodes to monitor the master we created above us

Along with the variables listed above, Sentinel has a number of its own configurables just as Redis server does. These are prefixed with `redis_sentinel_`, and are enumerated in the **Role Variables** section below.

### Multiple role inclusions

Should you need to execute the role several times, have a look at `test/test_all.yml` to see how to proceed. See [here](https://github.com/DavidWittman/ansible-redis/issues/133) and [here](https://github.com/DavidWittman/ansible-redis/issues/193) for context.


## Advanced Options

Expand Down
4 changes: 2 additions & 2 deletions handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
---
- name: "restart redis {{ redis_port }}"
- name: "restart redis"
service:
name: "{{ redis_service_name }}"
state: restarted
when: redis_as_service

- name: "restart sentinel {{ redis_sentinel_port }}"
- name: "restart sentinel"
service:
name: sentinel_{{ redis_sentinel_port }}
state: restarted
Expand Down
2 changes: 1 addition & 1 deletion meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
galaxy_info:
author: David Wittman
description: Highly configurable role to install Redis and Redis Sentinel from source
min_ansible_version: 1.9.0
min_ansible_version: 2.4.0
license: MIT
platforms:
- name: Ubuntu
Expand Down
6 changes: 3 additions & 3 deletions tasks/sentinel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,21 +107,21 @@
dest: /etc/redis/sentinel_{{ redis_sentinel_port }}.conf
owner: "{{ redis_user }}"
mode: 0640
notify: "restart sentinel {{ redis_sentinel_port }}"
notify: "restart sentinel"

- name: add sentinel init config file
template:
dest: /etc/sysconfig/sentinel_{{ redis_sentinel_port }}
src: redis.init.conf.j2
when: ansible_os_family == "RedHat"
notify: "restart sentinel {{ redis_sentinel_port }}"
notify: "restart sentinel"

- name: add sentinel init config file
template:
dest: /etc/default/sentinel_{{ redis_sentinel_port }}
src: redis.init.conf.j2
when: ansible_os_family == "Debian"
notify: "restart sentinel {{ redis_sentinel_port }}"
notify: "restart sentinel"

# Flush handlers before ensuring the service is started to prevent
# a start and then restart
Expand Down
6 changes: 3 additions & 3 deletions tasks/server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,23 +107,23 @@
dest: /etc/redis/{{ redis_port }}.conf
owner: "{{ redis_user }}"
mode: 0640
notify: "restart redis {{ redis_port }}"
notify: "restart redis"

- name: add redis init config file
template:
dest: /etc/sysconfig/{{ redis_service_name }}
src: redis.init.conf.j2
mode: 0600
when: ansible_os_family == "RedHat"
notify: "restart redis {{ redis_port }}"
notify: "restart redis"

- name: add redis init config file
template:
dest: /etc/default/{{ redis_service_name }}
src: redis.init.conf.j2
mode: 0600
when: ansible_os_family == "Debian"
notify: "restart redis {{ redis_port }}"
notify: "restart redis"

# Flush handlers before ensuring the service is started to prevent
# a start and then restart
Expand Down
44 changes: 27 additions & 17 deletions test/test_all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,32 @@
redis_version: 3.0.7
redis_password: ant1r3z
redis_travis_ci: true
roles:
- role: ../../ansible-redis
redis_port: 7379
tasks:
- import_role:
name: ../../ansible-redis
vars:
redis_port: 7379

- role: ../../ansible-redis
redis_port: 8379
redis_slaveof: 127.0.0.1 7379
redis_local_facts: false
- meta: flush_handlers

- role: ../../ansible-redis
redis_sentinel: true
redis_sentinel_port: 27379
redis_sentinel_monitors:
- name: master01
host: 127.0.0.1
port: 7379
quorum: 1
auth_pass: "{{ redis_password }}"
redis_local_facts: false
- import_role:
name: ../../ansible-redis
vars:
redis_port: 8379
redis_slaveof: 127.0.0.1 7379
redis_local_facts: false

- meta: flush_handlers

- import_role:
name: ../../ansible-redis
vars:
redis_sentinel: true
redis_sentinel_port: 27379
redis_sentinel_monitors:
- name: master01
host: 127.0.0.1
port: 7379
quorum: 1
auth_pass: "{{ redis_password }}"
redis_local_facts: false