-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Cheat Sheet
The top file is used to map what SLS modules get loaded onto what minions via the state system.
file_roots:
base:
- /srv/salt
base:
'*':
- core
'os:Ubuntu':
- match: grain
- repos.ubuntu
apache:
pkg.installed:
- version: 2.2.23
service.running:
- enable: True
/var/www/index.html: # ID declaration
file: # state declaration
- managed # function
- source: salt://webserver/index.html
- user: root
- group: root
- mode: 644
- require: # requisite declaration
- pkg: apache # requisite reference
Manages files.
- absent – verify that a file or directory is absent
- accumulated - prepare accumulator which can be used in template in file.managed
- append – put some text at the end of file
- comment – comment out some lines
- directory – ensure that a directory is present
- exists – ensure that a directory or file is present
- managed – this file is managed by the salt master and can be run through templating system
- patch – apply a patch to a file
- recurse – recurse through a subdirectory on master
- rename – rename a file
- replace – edit a file
- symlink – create a symlink
- touch – create an empty file or update m/atime
- uncomment - uncomment lines in a file
/etc/http/conf/http.conf:
file.managed:
- source: salt://apache/http.conf
- user: root
- group: root
- mode: 644
- template: jinja
- context:
custom_var: "override"
- defaults:
custom_var: "default value"
other_var: 123
Manage software packages.
- installed – verify if a package is installed
- latest – verify that the package is the latest version
- purged - verify if the package is removed, if not removes the package and all configuration files
- removed – verify if the package is removed, if not removes the package
httpd:
pkg.installed
- repo: mycustomrepo
- skip_verify: True
- version: 2.0.6~ubuntu3
Manage system daemons.
- dead
- disabled
- enabled
- mod_watch
- running
apache:
service.running
- name: httpd
- enable: True
- sig: httpd
Execution of arbitrary commands.
- mod_watch
- run
- script
- wait
- wait_script
date > /tmp/salt-run:
cmd.run
The cron state module allows for user crontabs to be cleanly managed.
date > /tmp/crontest:
cron.present:
- user: root
- minute: 7
- hour: 2
file - provides file.managed-like functionality (templating, etc.) for a pre-made crontab file, to be assigned to a given user
present
The user module is used to create and manage user settings, users can be set as either absent or present.
fred:
user.present:
- fullname: Fred Jones
- shell: /bin/zsh
- home: /home/fred
- uid: 4000
- gid: 4000
- groups:
- wheel
- storage
- games
testuser:
user.absent
The group module is used to create and manage unix group settings, groups can be either present or absent.
- present
- absent
cheese:
group.present:
- gid: 7648
- system: True
Interaction with Git repositories.
https://github.com/saltstack/salt.git:
git.latest:
- rev: develop
- target: /tmp/salt
Management of addresses and names in hosts file.
salt-master:
host.present:
- ip: 192.168.0.42
Loading and unloading of kernel modules.
kvm_amd:
kmod.present
pcspkr:
kmod.absent
Mounting of filesystems.
/mnt/sdb:
mount.mounted:
- device: /dev/sdb1
- fstype: ext4
- mkmnt: True
- opts:
- defaults
Configuration of the Linux kernel using sysctrl.
vm.swappiness:
sysctl.present:
- value: 20