From 4023fa3d109013fe7e6e5ca7a069dce49e4720d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tadej=20Jane=C5=BE?= Date: Mon, 3 Nov 2014 13:32:49 +0100 Subject: [PATCH 1/2] Added support for using Debian/Ubuntu backports repository. To use the backports repository, user has to set variable: 'redis_debian_backports' to 'True'. --- defaults/main.yml | 9 +++++++++ tasks/main.yml | 6 +++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/defaults/main.yml b/defaults/main.yml index 1364882..df4bbad 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,5 +1,14 @@ --- +###################### +# Playbook variables # +###################### +# Whether to use Debian/Ubuntu backports repository when installing Redis +redis_debian_backports: False + +################### +# Redis variables # +################### redis_bind_address: "0.0.0.0" redis_port: 6379 redis_syslog_enabled: "yes" diff --git a/tasks/main.yml b/tasks/main.yml index 61dc503..c6da03a 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -19,7 +19,11 @@ when: ansible_os_family == "RedHat" - name: Install the Redis packages - apt: name={{ item }} state=present update_cache=yes + apt: + name: "{{ item }}" + state: present + update_cache: yes + default_release: "{{ ansible_distribution_release + '-backports' if redis_debian_backports else ansible_distribution_release }}" with_items: redis_ubuntu_pkg environment: env when: ansible_os_family == "Debian" From b12efefdf9597149b746ad65e15e608ebbf321f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tadej=20Jane=C5=BE?= Date: Fri, 7 Nov 2014 11:09:46 +0100 Subject: [PATCH 2/2] Splitted the task that installs Redis on Debian/Ubuntu into two. This was done to avoid using Jinja2's conditionals in the playbook, which is discouraged. --- tasks/main.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index c6da03a..a11d551 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -19,14 +19,20 @@ when: ansible_os_family == "RedHat" - name: Install the Redis packages + apt: name={{ item }} state=present update_cache=yes + with_items: redis_ubuntu_pkg + environment: env + when: ansible_os_family == "Debian" and not redis_debian_backports + +- name: Install the Redis packages apt: name: "{{ item }}" state: present update_cache: yes - default_release: "{{ ansible_distribution_release + '-backports' if redis_debian_backports else ansible_distribution_release }}" + default_release: "{{ ansible_distribution_release }}-backports" with_items: redis_ubuntu_pkg environment: env - when: ansible_os_family == "Debian" + when: ansible_os_family == "Debian" and redis_debian_backports - name: Copy the redis configuration file template: src=redis.conf.j2 dest={{ redis_conf_dest }}