Skip to content

Commit

Permalink
Add option to install from repo instead of from source (#280)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
Yannik and Yannik authored Nov 28, 2022
1 parent be85ed1 commit 90f4d63
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 5 deletions.
1 change: 1 addition & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
## Installation options
redis_version: 2.8.24
redis_install_dir: /opt/redis
redis_install_from_source: true
redis_dir: /var/lib/redis/{{ redis_port }}
redis_config_file_name: "{{ redis_port }}.conf"
redis_download_url: "http://download.redis.io/releases/redis-{{ redis_version }}.tar.gz"
Expand Down
8 changes: 8 additions & 0 deletions tasks/install_from_repo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
- name: Install redis from repo
package:
name: redis

- name: Install redis-sentinel from repo
package:
name: redis-sentinel
when: redis_sentinel
10 changes: 9 additions & 1 deletion tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,22 @@
- include: check_vars.yml

- include: download.yml
when: redis_install_from_source
tags:
- download

- include: dependencies.yml
when: redis_install_from_source
tags:
- install

- include: install.yml
- include: install_from_source.yml
when: redis_install_from_source
tags:
- install

- include: install_from_repo.yml
when: not redis_install_from_source
tags:
- install

Expand Down
5 changes: 3 additions & 2 deletions tasks/sentinel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
- default/redis_sentinel.init.j2
paths:
- ../templates
when: redis_as_service and ansible_service_mgr|default() != "systemd"
when: redis_as_service and ansible_service_mgr|default() != "systemd" and not (not redis_install_from_source and redis_service_name == 'redis')

- name: create sentinel systemd service
template:
Expand All @@ -33,7 +33,7 @@
paths:
- ../templates
register: sentinel_unit_file
when: redis_as_service and ansible_service_mgr|default() == "systemd"
when: redis_as_service and ansible_service_mgr|default() == "systemd" and not (not redis_install_from_source and redis_service_name == 'redis')

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

- name: reload systemd daemon
systemd:
Expand Down
5 changes: 3 additions & 2 deletions tasks/server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
- default/redis.init.j2
paths:
- ../templates
when: redis_as_service and ansible_service_mgr|default() != "systemd"
when: redis_as_service and ansible_service_mgr|default() != "systemd" and not (not redis_install_from_source and redis_service_name == 'redis')

- name: create redis systemd service
template:
Expand All @@ -33,7 +33,7 @@
paths:
- ../templates
register: redis_unit_file
when: redis_as_service and ansible_service_mgr|default() == "systemd"
when: redis_as_service and ansible_service_mgr|default() == "systemd" and not (not redis_install_from_source and redis_service_name == 'redis')

- name: create systemd tmpfiles configuration
template:
Expand All @@ -44,6 +44,7 @@
- redis_as_service
- ansible_service_mgr|default() == 'systemd'
- (redis_pidfile|dirname).startswith('/var/run') or (redis_pidfile|dirname).startswith('/run')
- not (not redis_install_from_source and redis_service_name == 'redis')

- name: reload systemd daemon
systemd:
Expand Down

0 comments on commit 90f4d63

Please sign in to comment.