Skip to content

Commit

Permalink
enh: Move source installation in splitted files
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel Mutel authored and smutel committed Jul 15, 2021
1 parent 1a8bb6f commit 53bc82a
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 13 deletions.
3 changes: 3 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
---
## Installation options
redis_install_method: "source"
redis_version: 2.8.24
redis_install_dir: /opt/redis
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"
redis_package: redis-server
redis_pin_package: false

redis_protected_mode: "yes"
# Set this to true to validate redis tarball checksum against vars/main.yml
Expand Down
6 changes: 6 additions & 0 deletions handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,9 @@
name: sentinel_{{ redis_sentinel_port }}
state: restarted
when: redis_as_service

- name: "disable redis"
service:
name: "{{ redis_service_name }}"
enabled: no
when: redis_as_service
16 changes: 14 additions & 2 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,31 @@
- include: check_vars.yml

- include: download.yml
when: redis_install_method == "source"
tags:
- download

- include: dependencies.yml
when: redis_install_method == "source"
tags:
- install

- include: install.yml
- include: setup.yml
tags:
- install

- include: package.yml
when: redis_install_method == "package"
tags:
- install

- include: source.yml
when: redis_install_method == "source"
tags:
- install

- include: server.yml
when: not redis_sentinel
when: redis_server
tags:
- config

Expand Down
29 changes: 29 additions & 0 deletions tasks/package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
- name: Set pin content
set_fact:
pin_content: |
{{ pin_content | default('') }}
Package: {{ item }}
Pin: version {{ redis_version }}
Pin-Priority: 1001
loop: "{{ redis_packages }}"

- name: Pin Redis release
copy:
dest: /etc/apt/preferences.d/redis
owner: root
group: root
mode: '0644'
content: "{{ pin_content }}"
when:
- redis_pin_package
- ansible_distribution == "Ubuntu" or ansible_distribution == "Debian"

- name: Install Redis package
package:
name: "{{ redis_packages }}"
state: present
notify: "disable redis"

- name: flush handlers to disable redis after install
meta: flush_handlers
4 changes: 2 additions & 2 deletions tasks/server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
service:
name: "{{ redis_service_name }}"
enabled: yes
when: redis_as_service
when: redis_as_service or redis_install_method == "package"

# Check then create log dir to prevent aggressively overwriting permissions
- name: check if log directory exists
Expand Down Expand Up @@ -85,7 +85,7 @@
owner: "{{ redis_user }}"
group: "{{ redis_group }}"
when: redis_logfile != '""'

- name: update permissions of log file if needed
file:
state: file
Expand Down
9 changes: 9 additions & 0 deletions tasks/setup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
- name: enable overcommit in sysctl
sysctl:
name: vm.overcommit_memory
value: "1"
state: present
reload: yes
ignoreerrors: yes
when: redis_travis_ci is not defined
9 changes: 0 additions & 9 deletions tasks/install.yml → tasks/source.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
---
- name: enable overcommit in sysctl
sysctl:
name: vm.overcommit_memory
value: "1"
state: present
reload: yes
ignoreerrors: yes
when: redis_travis_ci is not defined

- name: compile redis
shell: umask 0022 && make -j{{ ansible_processor_cores|default(1) + 1 }}{{ ' 32bit' if redis_make_32bit|bool else '' }}{{ ' BUILD_TLS=yes' if redis_make_tls|bool else '' }}
args:
Expand Down

0 comments on commit 53bc82a

Please sign in to comment.