State Management

States apply specific configurations to minions. See State Reference.

Any .sls file in File Section will be evaluated as a SaLt State file. Subdirectories can be referenced as packages via the dir name if there is an init.sls file present. Directories do not require .sls files for traversal.

Directly apply a state to a minion.
salt '*' state.sls {STATE FILE NAME} saltenv=prod
salt-call state.sls {STATE FILE NAME} saltenv=prod

Any state files may be referenced in other state files, using dotted access notation from that environments root to access them.

Example of state package use in top file.
ls -1 /srv/salt/static/prod/other/app/
init.sls
0644 salt salt /srv/salt/static/prod/top.sls
prod:
  'my_host';
    - other.app

Install a Package

0644 salt salt /src/salt/static/prod/apache.sls
apache2:
  pkg:
    - installed

Deploy File with Content from Server

ls -1 /srv/salt/static/prod/files/config
.bashrc
0644 salt salt /srv/salt/static/prod/top.sls
prod:
  /root/.bashrc
    file.managed:
      - user: root
      - group: root
      - mode: 0600
      - source: salt://files/config/.bashrc