Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move source installation in splitted files #261

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why disable redis here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we install redis on debian, it's enabled by default. There are two systemd config, one called redis-server.service and another called redis.service. I tried to override them with the role but it's not easy. I decided to disable them after installation to be able to install systemd config through the role.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not a perfect solution but I did'nt find any other ... Feel free to suggest me other one.


- 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