Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
The top file is used to map what SLS modules get loaded onto what minions via the state system.
Here is a simple example of file_roots in the master configuration:
file_roots: base: - /srv/salt
Here is a simple, single environment top.sls file:
base: '*': - core 'os:Ubuntu': - match: grain - repos.ubuntu
pkg / file / service
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
- 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.
apache: service.running - name: httpd - enable: True - sig: httpd
Execution of arbitrary commands.
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
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.
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