Skip to content

Instantly share code, notes, and snippets.

@bookwar
Last active June 23, 2017 15:04
Show Gist options
  • Save bookwar/f2c099721ff91038dc158d5e272c8e8f to your computer and use it in GitHub Desktop.
Save bookwar/f2c099721ff91038dc158d5e272c8e8f to your computer and use it in GitHub Desktop.
Overlay structure for salt configurations

Problem

There are two sources of salt configurations: base and overlay.

The goal is to use the base states and pillar data but ignore the base top file, using only the top files from overlay repo.

Prerequisites

Filesystem layout

/srv/salt/
          base/
                states/
                        top.sls
                        base_state.sls
                        another_base_state.sls
                pillars/
                        top.sls
                        base_pillar.sls
                        another_base_pillar.sls
          overlay/
                states/
                        top.sls
                        overlay_state.sls
                pillars/
                        top.sls
                        overlay_pillar.sls

Salt master paths configuration

file_roots:
  base:
    - /srv/salt/base/states
  overlay:
    - /srv/salt/overlay/states

pillar_roots:
  base:
    - /srv/salt/base/pillars
  overlay:
    - /srv/salt/overlay/pillars
    
env_order: ['base','overlay']

/srv/salt/base/states/top.sls

base:
  '*':
    - base_state
    - another_base_state

/srv/salt/base is read only

Desired behaviour

salt '*' highstate should trigger base_state and overlay_state, but not another_base_state

Possible Solution

  1. Configure salt-master to use another name for top.sls file Add to /etc/salt/master:
    state_top: overlay_top.sls
    
  2. Create /srv/salt/overlay/states/overlay_top.sls
    base:
      '*':
        - base_state
    
    overlay:
      '*':
        - overlay_state

salt-master will read only this top-file and ignore all top.sls files in the base environment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment