Skip to content

Commit

Permalink
Stretch support and major changes
Browse files Browse the repository at this point in the history
- use vagrant and docker for travis
- use '.conf.local' file for custom config (keep default config file)
  • Loading branch information
HanXHX committed Jun 30, 2017
1 parent 2d9b166 commit 8c3e349
Show file tree
Hide file tree
Showing 10 changed files with 217 additions and 726 deletions.
26 changes: 24 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,37 @@
env:
- PLATFORM=debian-jessie
- PLATFORM='docker-debian-jessie' ANSIBLE_VERSION='ansible>=2.0,<2.1'
- PLATFORM='docker-debian-stretch' ANSIBLE_VERSION='ansible>=2.0,<2.1'
- PLATFORM='docker-debian-jessie' ANSIBLE_VERSION='ansible>=2.1,<2.2'
- PLATFORM='docker-debian-stretch' ANSIBLE_VERSION='ansible>=2.1,<2.2'
- PLATFORM='docker-debian-jessie' ANSIBLE_VERSION='ansible>=2.2,<2.3'
- PLATFORM='docker-debian-stretch' ANSIBLE_VERSION='ansible>=2.2,<2.3'
- PLATFORM='docker-debian-jessie' ANSIBLE_VERSION='ansible>=2.3,<2.4'
- PLATFORM='docker-debian-stretch' ANSIBLE_VERSION='ansible>=2.3,<2.4'

sudo: required

dist: trusty

language: python

services:
- docker

before_install:
- wget https://releases.hashicorp.com/vagrant/1.9.5/vagrant_1.9.5_x86_64.deb
- sudo dpkg -i vagrant_1.9.5_x86_64.deb

install:
- pip install "$ANSIBLE_VERSION"

script:
- docker build -f tests/$PLATFORM.Dockerfile -t test-$PLATFORM . && docker run --name $PLATFORM test-$PLATFORM
- VAGRANT_DEFAULT_PROVIDER=docker vagrant up $PLATFORM
- >
VAGRANT_DEFAULT_PROVIDER=docker vagrant provision $PLATFORM
| grep -q 'changed=0.*failed=0'
&& (echo 'Idempotence test: pass' && exit 0)
|| (echo 'Idempotence test: fail' && exit 1)
- VAGRANT_DEFAULT_PROVIDER=docker vagrant status

notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ Install and configure [Redis](http://redis.io/). Manage replication.
Requirements
------------

- Debian Jessie.
- If you want to install Redis from backports, you must use add this repository.
- If redis is already installed by hand (or other process). Please uninstall and purge configuration files. This role uses default config file and overwrite config in another file.

Role Variables
--------------
Expand All @@ -22,7 +22,7 @@ Role Variables
Dependencies
------------

None. But you can add explicitely my [Dotdeb role](https://galaxy.ansible.com/list#/roles/3970) to have the latest version of Redis!
None. But you can add explicitely my [Dotdeb role](https://galaxy.ansible.com/list#/roles/3970) to have the latest version of Redis on Jessie!

Example Playbook
----------------
Expand Down
43 changes: 31 additions & 12 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,44 @@
Vagrant.configure("2") do |config|

vms = [
[ "debian-jessie", "debian/jessie64" ]
{ :name => "debian-jessie", :box => "debian/jessie64" },
{ :name => "debian-stretch", :box => "debian/stretch64" }
]

config.vm.provider "virtualbox" do |v|
v.cpus = 1
v.memory = 256
end
conts = [
{ :name => "docker-debian-jessie", :docker => "hanxhx/vagrant-ansible:debian8" },
{ :name => "docker-debian-stretch", :docker => "hanxhx/vagrant-ansible:debian9" }
]

vms.each do |vm|
config.vm.define vm[0] do |m|
m.vm.hostname = vm[0]
m.vm.box = vm[1]
m.vm.network "private_network", type: "dhcp"
config.vm.network "private_network", type: "dhcp"

conts.each do |opts|
config.vm.define opts[:name] do |m|
m.vm.provider "docker" do |d|
d.image = opts[:docker]
d.remains_running = true
d.has_ssh = true
end
m.vm.provision "ansible" do |ansible|
ansible.playbook = "tests/test.yml"
ansible.groups = { "test" => [ vm[0] ] }
ansible.verbose = 'vv'
ansible.sudo = true
ansible.sudo = true
end
end
end

vms.each do |opts|
config.vm.define opts[:name] do |m|
m.vm.box = opts[:box]
m.vm.provider "virtualbox" do |v|
v.cpus = 1
v.memory = 256
end
m.vm.provision "ansible" do |ansible|
ansible.playbook = "tests/test.yml"
ansible.verbose = 'vv'
ansible.sudo = true
end
end
end
end
92 changes: 40 additions & 52 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,62 +7,50 @@ redis_ulimit: null
# =====================
# Configuration
# =====================
redis_daemonize: 'yes'
redis_pidfile: '/var/run/redis/redis-server.pid'
redis_port: '6379'
redis_bind: '127.0.0.1'
redis_timeout: '0'
redis_tcp_keepalive: '0'
redis_loglevel: 'notice'
redis_logfile: '/var/log/redis/redis-server.log'
redis_databases: '16'
redis_save:
- '900 1'
- '300 10'
- '60 10000'
redis_stop_writes_on_bgsave_error: 'yes'
redis_rdbcompression: 'yes'
redis_rdbchecksum: 'yes'
redis_dbfilename: 'dump.rdb'
redis_dir: '/var/lib/redis'
redis_slave_serve_stale_data: 'yes'
redis_slave_read_only: 'yes'
redis_repl_disable_tcp_nodelay: 'no'
redis_slave_priority: '100'
redis_appendonly: 'no'
redis_appendfsync: 'everysec'
redis_no_appendfsync_on_rewrite: 'no'
redis_auto_aof_rewrite_percentage: '100'
redis_auto_aof_rewrite_min_size: '64mb'
redis_lua_time_limit: '5000'
redis_slowlog_log_slower_than: '10000'
redis_slowlog_max_len: '128'
redis_hash_max_ziplist_entries: '512'
redis_hash_max_ziplist_value: '64'
redis_list_max_ziplist_entries: '512'
redis_list_max_ziplist_value: '64'
redis_set_max_intset_entries: '512'
redis_zset_max_ziplist_entries: '128'
redis_zset_max_ziplist_value: '64'
redis_activerehashing: 'yes'
redis_client_output_buffer_limit:
- 'normal 0 0 0'
- 'slave 256mb 64mb 60'
- 'pubsub 32mb 8mb 60'
redis_hz: '10'
redis_aof_rewrite_incremental_fsync: 'yes'
redis_daemonize: null
redis_pidfile: null
redis_port: null
redis_bind: null
redis_timeout: null
redis_tcp_keepalive: null
redis_loglevel: null
redis_logfile: null
redis_databases: null
redis_save: []
redis_stop_writes_on_bgsave_error: null
redis_rdbcompression: null
redis_rdbchecksum: null
redis_dbfilename: null
redis_dir: null
redis_slave_serve_stale_data: null
redis_slave_read_only: null
redis_repl_disable_tcp_nodelay: null
redis_slave_priority: null
redis_appendonly: null
redis_appendfsync: null
redis_no_appendfsync_on_rewrite: null
redis_auto_aof_rewrite_percentage: null
redis_auto_aof_rewrite_min_size: null
redis_lua_time_limit: null
redis_slowlog_log_slower_than: null
redis_slowlog_max_len: null
redis_hash_max_ziplist_entries: null
redis_hash_max_ziplist_value: null
redis_list_max_ziplist_entries: null
redis_list_max_ziplist_value: null
redis_set_max_intset_entries: null
redis_zset_max_ziplist_entries: null
redis_zset_max_ziplist_value: null
redis_activerehashing: null
redis_client_output_buffer_limit: []
redis_hz: null
redis_aof_rewrite_incremental_fsync: null
redis_requirepass: null

# Example:
# redis_rename_command:
# - old: 'SET'
# new: 'obfucated___SET'
redis_rename_command: []
redis_rename: []

# Replication
redis_masterauth: null
redis_masterauth_masterip: null
redis_masterauth_masterport: null
redis_slaveof: null
redis_repl_ping_slave_period: null
redis_repl_timeout: null

Expand Down
4 changes: 3 additions & 1 deletion meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@ galaxy_info:
description: Redis for Debian
company:
license: GPLv2
min_ansible_version: 1.6
min_ansible_version: 2.0
platforms:
- name: Debian
versions:
- jessie
- stretch
galaxy_tags:
- database
- nosql
- debian
- keyvalue
- cache
- web
- redis
dependencies: []

23 changes: 17 additions & 6 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,32 @@
- 'redis_maxmemory_samples is none or redis_maxmemory_policy in redis_maxmemory_samples_policies'

- name: APT | Update cache
apt: >
update_cache=yes
cache_valid_time=3600
apt: update_cache=yes cache_valid_time=3600
changed_when: false

- name: APT | Install redis
apt: >
pkg=redis-server
state=present
default_release={{ redis_apt_target }}
default_release="{{ redis_apt_target }}"
- name: LINEINFILE | Add include in config file
lineinfile:
path: /etc/redis/redis.conf
line: "include /etc/redis/redis.conf.local"
insertafter: EOF
notify: restart redis

- name: COMMAND | Disable config multiline
command: sed -ri 's/^({{ item }}.*)/# \1/g' /etc/redis/redis.conf
with_items: ['save', 'client-output-buffer-limit']
changed_when: false
notify: restart redis

- name: TEMPLATE | Deploy Redis config file
template: >
src=etc/redis/redis.conf.j2
dest=/etc/redis/redis.conf
src=etc/redis/redis.conf.local.j2
dest=/etc/redis/redis.conf.local
notify: restart redis

- name: LINEINFILE | Manage ulimit
Expand Down
Loading

0 comments on commit 8c3e349

Please sign in to comment.