Skip to content

Commit 90f4d63

Browse files
authored
Add option to install from repo instead of from source (#280)
* Add option to install from repo instead of from source * Do not create init-script/systemd service/tmpfiles config when installing from distro package and using the default service name Co-authored-by: Yannik Sembritzki <yannik@sembritzki.org>
1 parent be85ed1 commit 90f4d63

File tree

5 files changed

+24
-5
lines changed

5 files changed

+24
-5
lines changed

defaults/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
## Installation options
33
redis_version: 2.8.24
44
redis_install_dir: /opt/redis
5+
redis_install_from_source: true
56
redis_dir: /var/lib/redis/{{ redis_port }}
67
redis_config_file_name: "{{ redis_port }}.conf"
78
redis_download_url: "http://download.redis.io/releases/redis-{{ redis_version }}.tar.gz"

tasks/install_from_repo.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
- name: Install redis from repo
2+
package:
3+
name: redis
4+
5+
- name: Install redis-sentinel from repo
6+
package:
7+
name: redis-sentinel
8+
when: redis_sentinel

tasks/main.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,22 @@
22
- include: check_vars.yml
33

44
- include: download.yml
5+
when: redis_install_from_source
56
tags:
67
- download
78

89
- include: dependencies.yml
10+
when: redis_install_from_source
911
tags:
1012
- install
1113

12-
- include: install.yml
14+
- include: install_from_source.yml
15+
when: redis_install_from_source
16+
tags:
17+
- install
18+
19+
- include: install_from_repo.yml
20+
when: not redis_install_from_source
1321
tags:
1422
- install
1523

tasks/sentinel.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
- default/redis_sentinel.init.j2
2020
paths:
2121
- ../templates
22-
when: redis_as_service and ansible_service_mgr|default() != "systemd"
22+
when: redis_as_service and ansible_service_mgr|default() != "systemd" and not (not redis_install_from_source and redis_service_name == 'redis')
2323

2424
- name: create sentinel systemd service
2525
template:
@@ -33,7 +33,7 @@
3333
paths:
3434
- ../templates
3535
register: sentinel_unit_file
36-
when: redis_as_service and ansible_service_mgr|default() == "systemd"
36+
when: redis_as_service and ansible_service_mgr|default() == "systemd" and not (not redis_install_from_source and redis_service_name == 'redis')
3737

3838
- name: create systemd tmpfiles configuration
3939
template:
@@ -44,6 +44,7 @@
4444
- redis_as_service
4545
- ansible_service_mgr|default() == "systemd"
4646
- (redis_sentinel_pidfile|dirname).startswith("/var/run") or (redis_sentinel_pidfile|dirname).startswith("/run")
47+
- not (not redis_install_from_source and redis_service_name == 'redis')
4748

4849
- name: reload systemd daemon
4950
systemd:

tasks/server.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
- default/redis.init.j2
2020
paths:
2121
- ../templates
22-
when: redis_as_service and ansible_service_mgr|default() != "systemd"
22+
when: redis_as_service and ansible_service_mgr|default() != "systemd" and not (not redis_install_from_source and redis_service_name == 'redis')
2323

2424
- name: create redis systemd service
2525
template:
@@ -33,7 +33,7 @@
3333
paths:
3434
- ../templates
3535
register: redis_unit_file
36-
when: redis_as_service and ansible_service_mgr|default() == "systemd"
36+
when: redis_as_service and ansible_service_mgr|default() == "systemd" and not (not redis_install_from_source and redis_service_name == 'redis')
3737

3838
- name: create systemd tmpfiles configuration
3939
template:
@@ -44,6 +44,7 @@
4444
- redis_as_service
4545
- ansible_service_mgr|default() == 'systemd'
4646
- (redis_pidfile|dirname).startswith('/var/run') or (redis_pidfile|dirname).startswith('/run')
47+
- not (not redis_install_from_source and redis_service_name == 'redis')
4748

4849
- name: reload systemd daemon
4950
systemd:

0 commit comments

Comments
 (0)