Skip to content
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ In this case the source archive is copied to the server over SSH rather than dow

To build 32-bit binaries of Redis (which can be used for [memory optimization](https://redis.io/topics/memory-optimization)), set `redis_make_32bit: true`. This installs the necessary dependencies (x86 glibc) on RHEL/Debian/SuSE and sets the option '32bit' when running make.

### Building with TLS support

To build Redis with [TLS support](https://redis.io/topics/encryption) (Added in version `6`), set `redis_make_tls: true`. This requires OpenSSL development libraries (e.g. libssl-dev on Debian/Ubuntu).

## Role Variables

Here is a list of all the default variables for this role, which are also available in defaults/main.yml. One of these days I'll format these into a table or something.
Expand All @@ -204,6 +208,8 @@ redis_verify_checksum: false
redis_tarball: false
# Set this to true to build 32-bit binaries of Redis
redis_make_32bit: false
# Set this to true to build redis with TLS support, available only for versions >= 6 (require OpenSSL development libraries)
redis_make_tls: false

redis_user: redis
redis_group: "{{ redis_user }}"
Expand All @@ -222,7 +228,7 @@ redis_local_facts: true
redis_service_name: "redis_{{ redis_port }}"

## Networking/connection options
redis_bind: 0.0.0.0
redis_bind: false
redis_port: 6379
redis_password: false
# Slave replication options
Expand Down
5 changes: 4 additions & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
## 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"
redis_download_url: "http://download.redis.io/redis-{{ redis_version }}.tar.gz"

redis_protected_mode: "yes"
# Set this to true to validate redis tarball checksum against vars/main.yml
Expand All @@ -13,6 +14,8 @@ redis_verify_checksum: false
redis_tarball: false
# Set this to true to build 32-bit binaries of Redis
redis_make_32bit: false
# Set this to true to build redis with TLS support, available only for versions >= 6 (require OpenSSL development libraries)
redis_make_tls: false

redis_user: redis
redis_group: "{{ redis_user }}"
Expand Down
16 changes: 9 additions & 7 deletions tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
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 '' }}
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:
chdir: /usr/local/src/redis-{{ redis_version }}
creates: /usr/local/src/redis-{{ redis_version }}/src/redis-server
Expand All @@ -20,12 +20,6 @@
state: directory
mode: 0755

- name: create /etc/redis
file:
path: /etc/redis
state: directory
mode: 0755

- name: check if redis user exists (ignore errors)
command: id {{ redis_user }}
ignore_errors: yes
Expand All @@ -48,6 +42,13 @@
system: yes
when: user_exists is failed

- name: create /etc/redis
file:
path: /etc/redis
state: directory
mode: 0755
owner: "{{ redis_user }}"

- name: create /var/run/redis
file:
path: /var/run/redis
Expand All @@ -64,6 +65,7 @@
command: ls -1 {{ redis_install_dir }}/bin
register: redis_binaries
changed_when: false
check_mode: false

- name: add redis binaries to alternatives
alternatives:
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
22 changes: 15 additions & 7 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,35 @@
---
- include: check_vars.yml
- include_tasks: check_vars.yml

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

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

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

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

- include_tasks: server.yml
when: not redis_sentinel
tags:
- config

- include: sentinel.yml
- include_tasks: sentinel.yml
when: redis_sentinel
tags:
- config

- include: local_facts.yml
- include_tasks: local_facts.yml
when: redis_local_facts|bool
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
84 changes: 56 additions & 28 deletions vars/main.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
# From https://github.com/antirez/redis-hashes
# Generate with:
# $ curl -s https://raw.githubusercontent.com/antirez/redis-hashes/master/README | gawk '/^hash/ { print gensub(/redis-(.*)\.tar\.gz/, "\\1", "g", $2) ": " $4 }'
# $ curl -s https://raw.githubusercontent.com/antirez/redis-hashes/master/README | gawk '/^hash/ { print gensub(/redis-(.*)\.tar\.gz/, "\\1", "g", $2) ": " $4 }' |sort --version-sort
redis_checksums:
2.6.17: b5423e1c423d502074cbd0b21bd4e820409d2003
2.8.0: 41fd86128995f06502954dd6d6269c22f5e389f7
2.8.0-rc5: bd27589b71a0b406b982485051f32b7c40c9d2c1
2.8.0-rc6: d13db76145a9844e2a3302f561e907056f9e21a0
2.8.0: 41fd86128995f06502954dd6d6269c22f5e389f7
2.8.1: 1bb493318ff6c0c87334eb95640b89a16e4357d8
2.8.2: 3be038b9d095ce3dece7918aae810d14fe770400
2.8.3: a751371eeed5f5f02965eb34d989c1963dd8d8c7
2.8.4: 79b156cc9d8bff5a022fdc6d28d5c42999ddcb4f
2.8.5: f0eb48609ff66ead3c7f06bbe8a8dd1aa7341b73
2.8.6: 8680046580c75987961241f2e1e417c242b91a49
2.8.7: acc369093ec74223e6da207921595187f7e64998
2.8.8: aa811f399db58c92c8ec5e48271d307e9ab8eb81
2.8.9: 003ccdc175816e0a751919cf508f1318e54aac1e
2.8.10: 339ddf82e01a16ad912d1c1d59b02f3fab58d9d9
2.8.11: 3e3a4603781514f239f040287d3ef1097eb02a76
2.8.1: 1bb493318ff6c0c87334eb95640b89a16e4357d8
2.8.12: 56c86a4f9eccaf29f934433c7c67a175e404b2f6
2.8.13: a72925a35849eb2d38a1ea076a3db82072d4ee43
2.8.14: fd0edc045f2b53057d7f6ab38e2fe99086c87e8d
Expand All @@ -21,16 +29,8 @@ redis_checksums:
2.8.21: 52f619d3d301fc7ae498a1d4cb4d44ecebc5b0f9
2.8.22: 78a70b32cdd3a4ccc58880d1821fb828d091bb36
2.8.23: 828fc5d4011e6141fabb2ad6ebc193e8f0d08cfa
2.8.2: 3be038b9d095ce3dece7918aae810d14fe770400
2.8.3: a751371eeed5f5f02965eb34d989c1963dd8d8c7
2.8.4: 79b156cc9d8bff5a022fdc6d28d5c42999ddcb4f
2.8.5: f0eb48609ff66ead3c7f06bbe8a8dd1aa7341b73
2.8.6: 8680046580c75987961241f2e1e417c242b91a49
2.8.7: acc369093ec74223e6da207921595187f7e64998
2.8.8: aa811f399db58c92c8ec5e48271d307e9ab8eb81
2.8.9: 003ccdc175816e0a751919cf508f1318e54aac1e
3.0.0: c75fd32900187a7c9f9d07c412ea3b3315691c65
3.0.0-rc1: f0934db86791e32053f8b21ddec5965793edff19
3.0.0: c75fd32900187a7c9f9d07c412ea3b3315691c65
3.0.1: fe1d06599042bfe6a0e738542f302ce9533dde88
3.0.2: a38755fe9a669896f7c5d8cd3ebbf76d59712002
3.0.3: 0e2d7707327986ae652df717059354b358b83358
Expand All @@ -39,11 +39,7 @@ redis_checksums:
3.0.6: 4b1c7b1201984bca8f7f9c6c58862f6928cf0a25
3.0.7: e56b4b7e033ae8dbf311f9191cf6fdf3ae974d1c
3.2.0: 0c1820931094369c8cc19fc1be62f598bc5961ca
3.2.10: 411c604a716104f7f5a326abfad32de9cea10f15f987bec45cf86f315e9e63a0
3.2.11: 31ae927cab09f90c9ca5954aab7aeecc3bb4da6087d3d12ba0a929ceb54081b5
3.2.1: 26c0fc282369121b4e278523fce122910b65fbbf
3.2.12: 98c4254ae1be4e452aa7884245471501c9aa657993e0318d88f048093e7f88fd
3.2.13: 862979c9853fdb1d275d9eb9077f34621596fec1843e3e7f2e2f09ce09a387ba
3.2.2: 3141be9757532139f445bd5f6f4fae293bc33d27
3.2.3: 92d6d93ef2efc91e595c8bf578bf72baff397507
3.2.4: f0fe685cbfdb8c2d8c74613ad8a5a5f33fba40c9
Expand All @@ -52,13 +48,12 @@ redis_checksums:
3.2.7: 6889af053020cd72ebb16805ead0ce9b3a69a9ef
3.2.8: 6780d1abb66f33a97aad0edbe020403d0a15b67f
3.2.9: 6eaacfa983b287e440d0839ead20c2231749d5d6b78bbe0e0ffa3a890c59ff26
3.2.10: 411c604a716104f7f5a326abfad32de9cea10f15f987bec45cf86f315e9e63a0
3.2.11: 31ae927cab09f90c9ca5954aab7aeecc3bb4da6087d3d12ba0a929ceb54081b5
3.2.12: 98c4254ae1be4e452aa7884245471501c9aa657993e0318d88f048093e7f88fd
3.2.13: 862979c9853fdb1d275d9eb9077f34621596fec1843e3e7f2e2f09ce09a387ba
4.0.0: d539ae309295721d5c3ed7298939645b6f86ab5d25fdf2a0352ab575c159df2d
4.0.10: 1db67435a704f8d18aec9b9637b373c34aa233d65b6e174bdac4c1b161f38ca4
4.0.11: fc53e73ae7586bcdacb4b63875d1ff04f68c5474c1ddeda78f00e5ae2eed1bbb
4.0.1: 2049cd6ae9167f258705081a6ef23bb80b7eff9ff3d0d7481e89510f27457591
4.0.12: 6447259d2eed426a949c9c13f8fdb2d91fb66d9dc915dd50db13b87f46d93162
4.0.13: 17d955227966dcd68590be6139e5fe7f2d19fc4fb7334248a904ea9cdd30c1d4
4.0.14: 1e1e18420a86cfb285933123b04a82e1ebda20bfb0a289472745a087587e93a7
4.0.2: b1a0915dbc91b979d06df1977fe594c3fa9b189f1f3d38743a2948c9f7634813
4.0.3: 412f2634e55fe19e8826fae47935a8efe1e60ba2a48a8953c65e7a6caa459e41
4.0.4: 35768145335e874b1b810e23494ad3daa6f442c3dc1d7e3784992ba50799c0cd
Expand All @@ -67,6 +62,14 @@ redis_checksums:
4.0.7: 1bba546d44fb40e1fd8be1a15e1a9cc6484bceeea0bbd52919eebc656661ecd1
4.0.8: ff0c38b8c156319249fec61e5018cf5b5fe63a65b61690bec798f4c998c232ad
4.0.9: df4f73bc318e2f9ffb2d169a922dec57ec7c73dd07bccf875695dbeecd5ec510
4.0.10: 1db67435a704f8d18aec9b9637b373c34aa233d65b6e174bdac4c1b161f38ca4
4.0.11: fc53e73ae7586bcdacb4b63875d1ff04f68c5474c1ddeda78f00e5ae2eed1bbb
4.0.12: 6447259d2eed426a949c9c13f8fdb2d91fb66d9dc915dd50db13b87f46d93162
4.0.13: 17d955227966dcd68590be6139e5fe7f2d19fc4fb7334248a904ea9cdd30c1d4
4.0.14: 1e1e18420a86cfb285933123b04a82e1ebda20bfb0a289472745a087587e93a7
5.0-rc4: bfc7a27d3ba990e154e5b56484061f01962d40b7c77b520ed7a940914b267cec
5.0-rc5.tar.gz: d070c8a3514e40da5cef9ec26dfd594df0468c203c36398ef2d359a32502b548
5.0-rc6: 5e5ffc9184021178c1d89375c5132a2b872a9f77569e8c08ccbdf322acff7ace
5.0.0: 70c98b2d0640b2b73c9d8adb4df63bcb62bad34b788fe46d1634b6cf87dc99a4
5.0.1: 82a67c0eec97f9ad379384c30ec391b269e17a3e4596393c808f02db7595abcb
5.0.2: 937dde6164001c083e87316aa20dad2f8542af089dfcb1cbb64f9c8300cd00ed
Expand All @@ -77,14 +80,39 @@ redis_checksums:
5.0.7: 61db74eabf6801f057fd24b590232f2f337d422280fd19486eca03be87d3a82b
5.0.8: f3c7eac42f433326a8d981b50dba0169fdfaf46abb23fcda2f933a7552ee4ed7
5.0.9: 53d0ae164cd33536c3d4b720ae9a128ea6166ebf04ff1add3b85f1242090cb85
5.0-rc4: bfc7a27d3ba990e154e5b56484061f01962d40b7c77b520ed7a940914b267cec
5.0-rc5.tar.gz: d070c8a3514e40da5cef9ec26dfd594df0468c203c36398ef2d359a32502b548
5.0-rc6: 5e5ffc9184021178c1d89375c5132a2b872a9f77569e8c08ccbdf322acff7ace
6.0.0: 16d13ec1c3255206deb4818ed444dca6dda1482b551736f0033253c211b788fc
6.0.1: b8756e430479edc162ba9c44dc89ac394316cd482f2dc6b91bcd5fe12593f273
6.0.2: 9c37cd4228a57e82e7037094751c63349302b0b86c5e30b778a63a802dfd0109
6.0.3: bca46dce81fe92f7b2de4cf8ae41fbc4b94fbd5674def7f12c87e7f9165cbb3a
5.0.10: e30a5e7d1593a715cdda2a82deb90190816d06c9d1dc1ef5b36874878c683382
5.0.11: 418135c453a94aac24c24243b041fb978fcc3ea4e1e1f996c1d64b16ae6ac1aa
5.0.12: 7040eba5910f7c3d38f05ea5a1d88b480488215bdbd2e10ec70d18380108e31e
5.0.13: 2b617aa2d6ad66c6a5d99fc8590c6b83b40d391fd1184c6eeab30df31f6a7208
5.0.14: 3ea5024766d983249e80d4aa9457c897a9f079957d0fb1f35682df233f997f32
6.0-rc1: 3e11d148de0b3c3e573a31b6abb3cba56812aefe3f9a917a445768cc510b5fe3
6.0-rc2: 60dc45d8ab41de59a12d1163f7f79911f289f4d73b5066e027942eddec259a88
6.0-rc3: aa5916b7ee9a7098032cb875f3f0bfb4405f6e2533d7f6284dfbca21f55fc289
6.0-rc4: 7fdc37fd9451571e90186115a67d7595d49206f90bd7c2b7505b197fd6544358
6.0.0: 16d13ec1c3255206deb4818ed444dca6dda1482b551736f0033253c211b788fc
6.0.1: b8756e430479edc162ba9c44dc89ac394316cd482f2dc6b91bcd5fe12593f273
6.0.2: 9c37cd4228a57e82e7037094751c63349302b0b86c5e30b778a63a802dfd0109
6.0.3: bca46dce81fe92f7b2de4cf8ae41fbc4b94fbd5674def7f12c87e7f9165cbb3a
6.0.4: 3337005a1e0c3aa293c87c313467ea8ac11984921fab08807998ba765c9943de
6.0.5: 42cf86a114d2a451b898fcda96acd4d01062a7dbaaad2801d9164a36f898f596
6.0.6: 12ad49b163af5ef39466e8d2f7d212a58172116e5b441eebecb4e6ca22363d94
6.0.7: c2aaa1a4c7e72c70adedf976fdd5e1d34d395989283dab9d7840e0a304bb2393
6.0.8: 04fa1fddc39bd1aecb6739dd5dd73858a3515b427acd1e2947a66dadce868d68
6.0.9: dc2bdcf81c620e9f09cfd12e85d3bc631c897b2db7a55218fd8a65eaa37f86dd
6.0.10: 79bbb894f9dceb33ca699ee3ca4a4e1228be7fb5547aeb2f99d921e86c1285bd
6.0.11: c927f2d110e88fda308526a1809a4d7dfcd004319f0de66d40a58a42aec23c5f
6.0.12: f16ad973d19f80f121e53794d5eb48a997e2c6a85b5be41bb3b66750cc17bf6b
6.0.13: 3049763f4553ddd5a69552f41da3dd7dde9fbc524dbb15e517fee24cc73b790c
6.0.14: c3e60c928b183ca9fe8e878936a6f8ba99e0441b9b6e04d2412a750ea576c649
6.0.15: 4bc295264a95bc94423c162a9eee66135a24a51eefe5f53f18fc9bde5c3a9f74
6.0.16: 3639bbf29aca1a1670de1ab2ce224d6511c63969e7e590d3cdf8f7888184fa19
6.2-rc1: 92fc13f57b31cb6425c590b9c6b0bf611450f66b18fe92b9d5893b3a9760c438
6.2-rc2: 7153bbbd751f61ea70e649e0d19be6e7e78da9864527d46d10519e9a03cb0924
6.2-rc3: f35bba2af553fb58b2068ee581f316cefe0c00041e48fc944bd962e65777851c
6.2.0: 67d624c25d962bd68aff8812a135df85bad07556b8825f3bcd5b522a9932dbca
6.2.1: cd222505012cce20b25682fca931ec93bd21ae92cb4abfe742cf7b76aa907520
6.2.2: 7a260bb74860f1b88c3d5942bf8ba60ca59f121c6dce42d3017bed6add0b9535
6.2.3: 98ed7d532b5e9671f5df0825bb71f0f37483a16546364049384c63db8764512b
6.2.4: ba32c406a10fc2c09426e2be2787d74ff204eb3a2e496d87cff76a476b6ae16e
6.2.5: 4b9a75709a1b74b3785e20a6c158cab94cf52298aa381eea947a678a60d551ae
6.2.6: 5b2b8b7a50111ef395bf1c1d5be11e6e167ac018125055daa8b5c2317ae131ab