├── LICENSE ├── README.md ├── defaults └── main.yml ├── handlers └── main.yml ├── meta └── main.yml ├── tasks └── main.yml └── templates └── redis.conf.j2 /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Jason Barr 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Note: this package isn't maintained anymore, but if you need to do something like upgrade the PHP version there are several forks available. 2 | 3 | Trellis Redis 4 | ========= 5 | 6 | Ansible role to add Redis to Trellis server provisioning 7 | 8 | This role is made to be used with [Trellis](https://github.com/roots/trellis). 9 | It installs and configures Redis and the PECL php-redis extension on your server. 10 | 11 | Get Started 12 | ---------------- 13 | Add the role to the requirements.yml file of Trellis : 14 | ```yaml 15 | - name: trellis-redis 16 | src: marksabbath.trellis_redis 17 | version: 0.2.6 18 | ``` 19 | 20 | Run `ansible-galaxy install -r requirements.yml` to install the new role.
21 | Then, add the role into both server.yml **and** dev.yml: 22 | ```yaml 23 | roles: 24 | ... other Trellis roles ... 25 | - { role: trellis-redis, tags: [redis]} 26 | ``` 27 | 28 | After adding the role to the above files and running the install, provision your Vagrant box with `vagrant reload --provision` (if it's running) or `vagrant provision` (if it's not). If you haven't provisioned the box yet simply run `vagrant up`. 29 | -------------------------------------------------------------------------------- /defaults/main.yml: -------------------------------------------------------------------------------- 1 | # Basic config options 2 | 3 | redis_config_path: /etc/redis 4 | redis_daemonize: 'yes' 5 | redis_pidfile: /run/redis/redis-server.pid 6 | redis_port: 6379 7 | redis_unixsocket: '' 8 | redis_requirepass: '' 9 | redis_bind: 127.0.0.1 10 | redis_timeout: 0 11 | redis_tcp_keepalive: 0 12 | redis_loglevel: notice 13 | redis_logfile: /var/log/redis/redis-server.log 14 | redis_databases: 16 15 | 16 | redis_save: 17 | - 900 1 18 | - 300 10 19 | - 60 10000 20 | 21 | redis_stop_writes_on_bgsave_error: 'yes' 22 | redis_rdbcompression: 'yes' 23 | redis_rdbchecksum: 'yes' 24 | redis_dbfilename: dump.rdb 25 | redis_dir: /var/lib/redis 26 | redis_maxclients: 10000 27 | 28 | # Max memory values 29 | redis_maxmemory: 128mb 30 | redis_maxmemory_policy: noeviction 31 | redis_maxmemory_samples: 3 32 | 33 | redis_appendonly: 'no' 34 | redis_appendfilename: appendonly.aof 35 | redis_appendfsync: everysec 36 | redis_no_appendfsync_on_rewrite: 'no' 37 | redis_auto_aof_rewrite_percentage: 100 38 | redis_auto_aof_rewrite_min_size: 128mb 39 | redis_aof_load_truncated: 'yes' 40 | redis_lua_time_limit: 5000 41 | redis_slowlog_slower_than: 10000 42 | redis_slowlog_max_len: 128 43 | redis_latency_monitor_threshold: 0 44 | 45 | redis_hash_max_ziplist_entries: 512 46 | redis_hasn_max_ziplist_value: 64 47 | redis_list_max_ziplist_entries: 512 48 | redis_list_max_ziplist_value: 64 49 | redis_set_max_intset_entries: 512 50 | redis_zset_max_ziplist_entries: 128 51 | redis_zset_max_ziplist_value: 64 52 | redis_hll_sparse_max_bytes: 3000 53 | redis_activerehashing: 'yes' 54 | 55 | redis_client_output_buffer_limit: 56 | - normal 0 0 0 57 | 58 | redis_hz: 10 59 | redis_aof_rewrite_incremental_fsync: 'yes' 60 | -------------------------------------------------------------------------------- /handlers/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Start Redis 3 | service: 4 | name: redis-server 5 | state: started 6 | 7 | - name: Restart Redis 8 | service: 9 | name: redis-server 10 | state: restarted 11 | 12 | - name: Reload Redis 13 | service: 14 | name: redis-server 15 | state: reloaded 16 | 17 | - name: Restart php-fpm 18 | service: 19 | name: php7.4-fpm 20 | state: restarted 21 | -------------------------------------------------------------------------------- /meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | galaxy_info: 3 | author: Jason Barr 4 | description: Install and configure Redis in Trellis as an object cache. 5 | company: OnFocus Media 6 | license: MIT 7 | min_ansible_version: 2.2 8 | platforms: 9 | - name: Ubuntu 10 | versions: 11 | - xenial 12 | galaxy_tags: 13 | - roots 14 | - trellis 15 | - redis 16 | - cache 17 | - system 18 | dependencies: [] 19 | -------------------------------------------------------------------------------- /tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Install Redis 3 | apt: 4 | pkg: redis-server 5 | state: installed 6 | update_cache: true 7 | notify: Start Redis 8 | 9 | - name: Install php-redis 10 | apt: 11 | pkg: php-redis 12 | state: installed 13 | update_cache: true 14 | notify: Restart php-fpm 15 | 16 | - name: Configure Redis 17 | template: 18 | src: redis.conf.j2 19 | dest: "{{ redis_config_path }}/redis.conf" 20 | mode: 0640 21 | notify: Restart Redis 22 | 23 | - name: Set Redis to Run on Boot 24 | service: 25 | name: redis-server 26 | state: started 27 | enabled: yes 28 | -------------------------------------------------------------------------------- /templates/redis.conf.j2: -------------------------------------------------------------------------------- 1 | # {{ ansible_managed }} 2 | 3 | daemonize {{ redis_daemonize }} 4 | pidfile {{ redis_pidfile }} 5 | port {{ redis_port }} 6 | 7 | {% if redis_unixsocket %} 8 | unixsocket {{ redis_unixsocket }} 9 | {% endif %} 10 | 11 | {% if redis_requirepass %} 12 | requirepass {{ redis_requirepass }} 13 | {% endif %} 14 | 15 | bind {{ redis_bind }} 16 | timeout {{ redis_timeout }} 17 | tcp-keepalive {{ redis_tcp_keepalive }} 18 | loglevel {{ redis_loglevel }} 19 | logfile {{ redis_logfile }} 20 | databases {{ redis_databases }} 21 | 22 | {% for save in redis_save %} 23 | save {{ save }} 24 | {% endfor %} 25 | 26 | stop-writes-on-bgsave-error {{ redis_stop_writes_on_bgsave_error }} 27 | rdbcompression {{ redis_rdbcompression }} 28 | rdbchecksum {{ redis_rdbchecksum }} 29 | dbfilename {{ redis_dbfilename }} 30 | dir {{ redis_dir }} 31 | 32 | maxclients {{ redis_maxclients }} 33 | maxmemory {{ redis_maxmemory }} 34 | maxmemory-policy {{ redis_maxmemory_policy }} 35 | maxmemory-samples {{ redis_maxmemory_samples }} 36 | 37 | appendonly {{ redis_appendonly }} 38 | appendfilename {{ redis_appendfilename }} 39 | appendfsync {{ redis_appendfsync }} 40 | no-appendfsync-on-rewrite {{ redis_no_appendfsync_on_rewrite }} 41 | auto-aof-rewrite-percentage {{ redis_auto_aof_rewrite_percentage }} 42 | auto-aof-rewrite-min-size {{ redis_auto_aof_rewrite_min_size }} 43 | aof-load-truncated {{ redis_aof_load_truncated }} 44 | lua-time-limit {{ redis_lua_time_limit }} 45 | slowlog-log-slower-than {{ redis_slowlog_slower_than }} 46 | slowlog-max-len {{ redis_slowlog_max_len }} 47 | latency-monitor-threshold {{ redis_latency_monitor_threshold }} 48 | 49 | hash-max-ziplist-entries {{ redis_hash_max_ziplist_entries }} 50 | hash-max-ziplist-value {{ redis_hasn_max_ziplist_value }} 51 | list-max-ziplist-entries {{ redis_list_max_ziplist_entries }} 52 | list-max-ziplist-value {{ redis_list_max_ziplist_value }} 53 | set-max-intset-entries {{ redis_set_max_intset_entries }} 54 | zset-max-ziplist-entries {{ redis_zset_max_ziplist_entries }} 55 | zset-max-ziplist-value {{ redis_zset_max_ziplist_value }} 56 | hll-sparse-max-bytes {{ redis_hll_sparse_max_bytes }} 57 | activerehashing {{ redis_activerehashing }} 58 | 59 | {% for client in redis_client_output_buffer_limit %} 60 | client-output-buffer-limit {{ client }} 61 | {% endfor %} 62 | 63 | hz {{ redis_hz }} 64 | aof-rewrite-incremental-fsync {{ redis_aof_rewrite_incremental_fsync }} 65 | --------------------------------------------------------------------------------