Skip to content

Instantly share code, notes, and snippets.

@erchn
erchn / top.sls.yaml
Created November 24, 2013 16:29
auto-assign states to a minion based on cluster name if they exist on the master. The concept shamelessly copied from another community member.
{# ######################################################################################### #}
{# ######################################################################################### #}
{# this block of code auto applies salt states to a given minion if they exist on the master #}
{% set id = grains['id'] %}
{# web01 host id = 'web' cluster id, allow a custom grain or pillar named 'cluster' to override #}
{% set cluster = salt['config.get']('cluster', id.split('.')[0].rstrip('0123456789')) %}
{# all available states on the master #}
{% set states = salt['cp.list_master']() %}
trigger script when updated:
file.managed:
- name: /usr/local/bin/script.sh
- source: salt://script.sh
- mode: 700
cmd.wait:
- name: /usr/local/bin/script.sh
- cwd: /tmp
- watch:
@erchn
erchn / srv-pillar-top.sls.yaml
Last active December 21, 2015 11:18
salt user management
base:
'*':
# account details are available everywhere
- users.accounts
# ops group data
- users.ops
# individual users on a given machine
- users.nodeusers
'web*':