CentOS 7
Sponsored Link

Salt : Use Salt State File#12016/10/08

 
This is How to use Salt State File.
Salt State File is just the configuration file written as YAML file.
[1] First, define root directory to put State files.
The default location is /srv/salt. (this example shows to configure with default location)
[root@dlp ~]#
vi /etc/salt/master
# line 417: uncomment and define root directory

file_roots:
  base:
    - /srv/salt

[root@dlp ~]#
mkdir /srv/salt

[2] To put State files under the root directory, it's possible to apply configuration to Minions with salt command.
For example below, Install wget package to Minions.
# (any file name).sls

[root@dlp ~]#
vi /srv/salt/default.sls
# create new

install_wget:
  pkg.installed:
    - name: wget

# apply to node01

[root@dlp ~]#
salt "node01.srv.world" state.sls default

node01.srv.world:
----------
          ID: install_wget
    Function: pkg.installed
        Name: wget
      Result: True
     Comment: The following packages were installed/updated: wget

.....
.....

Summary
------------
Succeeded: 1 (changed=1)
Failed:    0
------------
Total states run:     1

# verify

[root@dlp ~]#
salt "node01.srv.world" cmd.run 'rpm -q wget'

node01.srv.world:
    wget-1.14-10.el7_0.1.x86_64
Matched Content