Skip to content

Commit

Permalink
add support for install in LXCcontainers
Browse files Browse the repository at this point in the history
  • Loading branch information
siavashsardari committed Jan 18, 2021
1 parent 2cd295d commit b8e4ceb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
12 changes: 11 additions & 1 deletion tasks/install.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
---
- name: check if inside container
command: grep -qa container=lxc /proc/1/environ
register: container_env

- name: set fact inside container
set_fact:
inside_container: "{% if container_env.rc == 0 %}True{% else %}False{% endif %}"

- 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
when:
- redis_travis_ci is not defined
- container_env.rc != 0

- name: compile redis
shell: umask 0022 && make -j{{ ansible_processor_cores|default(1) + 1 }}{{ ' 32bit' if redis_make_32bit|bool else '' }}
Expand Down
6 changes: 3 additions & 3 deletions templates/default/redis.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ OOMScoreAdjust={{ redis_oom_score_adjust }}
{% endif %}

UMask=007
PrivateTmp=yes
PrivateTmp={{ 'no' if inside_container else 'yes' }}
LimitNOFILE={{ redis_nofile_limit }}
PrivateDevices=yes
ProtectHome=yes
PrivateDevices={{ 'no' if inside_container else 'yes' }}
ProtectHome={{ 'no' if inside_container else 'yes' }}
ReadOnlyDirectories=/
ReadWriteDirectories=-{{ redis_dir }}
{% if redis_logfile != '""' %}
Expand Down
6 changes: 3 additions & 3 deletions templates/default/redis_sentinel.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ OOMScoreAdjust={{ redis_sentinel_oom_score_adjust }}
{% endif %}

UMask=007
PrivateTmp=yes
PrivateTmp={{ 'no' if inside_container else 'yes' }}
LimitNOFILE={{ redis_nofile_limit }}
PrivateDevices=yes
ProtectHome=yes
PrivateDevices={{ 'no' if inside_container else 'yes' }}
ProtectHome={{ 'no' if inside_container else 'yes' }}
ReadOnlyDirectories=/
ReadWriteDirectories=-{{ redis_sentinel_dir }}
{% if redis_sentinel_logfile != '""' %}
Expand Down

0 comments on commit b8e4ceb

Please sign in to comment.