From eb5aa6f7c5007f19031a2a0de199c891d9ddacec Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Thu, 22 Dec 2016 16:30:33 +0100 Subject: [PATCH] library/roles/redis: Cleanup the redis role. --- redis/defaults/main.yml | 1 + redis/tasks/main.yml | 45 +++++++++++++++++++++++++++-------------- 2 files changed, 31 insertions(+), 15 deletions(-) diff --git a/redis/defaults/main.yml b/redis/defaults/main.yml index e1f4a8f2..495e0f78 100644 --- a/redis/defaults/main.yml +++ b/redis/defaults/main.yml @@ -1,4 +1,5 @@ --- +redis_install: False redis_enabled: True # https://launchpad.net/~chris-lea/+archive/ubuntu/redis-server redis_ppa_repo: ppa:chris-lea/redis-server diff --git a/redis/tasks/main.yml b/redis/tasks/main.yml index 687fdcfd..07f99e1d 100644 --- a/redis/tasks/main.yml +++ b/redis/tasks/main.yml @@ -1,19 +1,34 @@ --- -- name: Install the Redis PPA - apt_repository: repo='{{ redis_ppa_repo }}' update_cache=yes - tags: redis +- block: + - name: Install the Redis PPA + apt_repository: repo='{{ redis_ppa_repo }}' update_cache=yes -- name: Install the Redis package - apt: pkg={{ item }} state=present - with_items: '{{ redis_server_pkg }}' - tags: redis + - name: Install the Redis packages + apt: pkg={{ item }} state={[ redis_pkg_state }} cache_valid_time=1800 + with_items: '{{ redis_server_pkg }}' -- name: Start and enable the Redis service - service: name=redis-server state=started enabled=yes - when: redis_enabled - tags: redis + - name: Start and enable the Redis service + service: name=redis-server state=started enabled=yes + when: redis_enabled -- name: Stop and disable the Redis service - service: name=redis-server state=stopped enabled=no - when: not redis_enabled - tags: redis + - name: Stop and disable the Redis service + service: name=redis-server state=stopped enabled=no + when: not redis_enabled + + when: redis_install + tags: redis + + +- block: + - name: Stop and disable the Redis service + service: name=redis-server state=stopped enabled=no + + - name: Remove the Redis packages + apt: pkg={{ item }} state=absent + with_items: '{{ redis_server_pkg }}' + + - name: Remove the Redis PPA + apt_repository: repo='{{ redis_ppa_repo }}' state=absent update_cache=yes + + when: not redis_install + tags: redis