Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/wikioasis/salt/llms.txt

Use this file to discover all available pages before exploring further.

The redis Salt state installs redis-server, renders a Jinja-templated redis.conf from pillar data, and keeps the service running and restarted whenever the configuration changes. Each redis* VM in the fleet carries a host-specific pillar file that overrides the maxmemory limit and eviction policy, while all other tunables inherit cluster-wide defaults from the base redis pillar.

State overview

1

Package installation

Installs the redis-server package via pkg.installed.
2

Configuration file

Renders /etc/redis/redis.conf from salt://redis/files/redis.conf.jinja, owned by root:redis, mode 0640. All values are sourced from the redis pillar key.
3

Service management

Ensures redis-server is running and enabled at boot, restarting automatically whenever the config file changes.
# salt/redis/init.sls
install_redis:
  pkg.installed:
    - name: redis-server

/etc/redis/redis.conf:
  file.managed:
    - source: salt://redis/files/redis.conf.jinja
    - template: jinja
    - user: root
    - group: redis
    - mode: '0640'
    - require:
      - pkg: install_redis

redis-server:
  service.running:
    - enable: True
    - watch:
      - file: /etc/redis/redis.conf

Configuration template

The template is intentionally minimal — every directive maps directly to a pillar key with a safe default, making it easy to override individual settings per host.
{%- set cfg = salt['pillar.get']('redis', {}) %}
{%- set saves = cfg.get('save', ['900 1', '300 10', '60 10000']) %}
# Managed by Salt — do not edit manually.

bind {{ cfg.get('bind', '127.0.0.1') }}
port {{ cfg.get('port', 6379) }}
protected-mode {{ cfg.get('protected_mode', 'yes') }}

timeout {{ cfg.get('timeout', 0) }}
tcp-keepalive {{ cfg.get('tcp_keepalive', 300) }}

loglevel {{ cfg.get('loglevel', 'notice') }}
logfile "{{ cfg.get('logfile', '') }}"

databases {{ cfg.get('databases', 16) }}

{%- for s in saves %}
save {{ s }}
{%- endfor %}

maxmemory {{ cfg.get('maxmemory', 0) }}
maxmemory-policy {{ cfg.get('maxmemory_policy', 'noeviction') }}

{%- if cfg.get('requirepass') %}
requirepass {{ cfg.get('requirepass') }}
{%- endif %}

appendonly {{ cfg.get('appendonly', 'no') }}
appendfsync {{ cfg.get('appendfsync', 'everysec') }}

dir /var/lib/redis

Pillar reference

All keys sit under the top-level redis mapping. The cluster-wide defaults are defined in pillar/redis/init.sls and selectively overridden in per-host pillar files.
KeyDefaultDescription
bind127.0.0.1Interface(s) Redis listens on; fleet uses 0.0.0.0 for internal reachability
port6379TCP port
protected_modeyesReject connections from non-loopback clients if no password set; fleet sets no
timeout0Idle connection timeout in seconds; 0 disables
tcp_keepalive300TCP keepalive interval in seconds
loglevelnoticeLogging verbosity (debug, verbose, notice, warning)
logfile""Log file path; empty string sends logs to stdout / journald
databases16Number of logical databases
maxmemory0Memory cap; 0 = unlimited. Use gb/mb suffix (e.g. 12gb)
maxmemory_policynoevictionEviction policy when maxmemory is reached
requirepass(unset)Optional password; omit the key entirely to disable AUTH
appendonlynoEnable AOF persistence (yes/no)
appendfsynceverysecAOF fsync strategy (always, everysec, no)
save['900 1', '300 10', '60 10000']RDB save checkpoints as a list of "seconds changes" strings
The maxmemory_policy for all MediaWiki caching instances is set to allkeys-lru, which evicts the least-recently-used key from the entire keyspace when the memory limit is reached. This is the correct policy for object caches where every key is expendable.

Pillar examples

# pillar/redis/init.sls — applied to every redis* minion
redis:
  bind: 0.0.0.0
  port: 6379
  timeout: 0
  tcp_keepalive: 300
  loglevel: notice
  logfile: ""
  databases: 16
  maxmemory: 0
  maxmemory_policy: noeviction
  protected_mode: "no"
  appendonly: "no"
  appendfsync: everysec
  save:
    - "900 1"
    - "300 10"
    - "60 10000"

Fleet topology

redis-us-east-011

Primary US-East cache node. 12 GB memory cap, allkeys-lru eviction. VM ID 140 on metal-us-east-01.

redis-us-east-012

Secondary US-East cache node. 3 GB memory cap, allkeys-lru eviction. VM ID 141 on metal-us-east-01.

redis-us-east-021

US-East-02 cache node. 3 GB memory cap, allkeys-lru eviction. Hosted on metal-us-east-02 at 10.0.2.90.

Applying the state

# Apply to all redis* minions
salt 'redis*' state.apply redis

# Apply to a specific instance
salt 'redis-us-east-011*' state.apply redis

# Verify rendered configuration on a minion
salt 'redis-us-east-011*' pillar.get redis

# Test configuration without applying
salt 'redis*' state.apply redis test=True
After applying, confirm Redis is accepting connections and respecting the memory cap with:
salt 'redis-us-east-011*' cmd.run 'redis-cli INFO memory | grep used_memory_human'

Build docs developers (and LLMs) love