This repository has been archived by the owner on Oct 12, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
05. SaltStack hello world
Khelil Sator edited this page Jul 17, 2017
·
12 revisions
# pip install git+https://github.com/saltstack/[email protected]
# salt --version
salt 2017.7.0-202-g3c8dee0 (Nitrogen)
The salt-master is configured via the master configuration file
The configuration file for the salt-master is located at /etc/salt/master
by default.
Example:
# more /etc/salt/master
file_roots:
base:
- /srv/salt
pillar_roots:
base:
- /srv/pillar
engines_dirs:
- /srv/engines
engines:
- junos_syslog:
port: 516
reactor:
- 'jnpr/syslog/*/UI_COMMIT_COMPLETED':
- /srv/reactor/on_commit.sls
nodegroups:
group1: 'L@ex4200-7,vqfx01'
group2:
- minion_1
- ex4200-7
group3: 'G@os_family:junos or minion_1'
# ifconfig ens33 | grep "inet addr"
inet addr:192.168.233.17 Bcast:192.168.233.255 Mask:255.255.255.0
to start it with a debug log level, use this command:
# salt-master -l debug
if you prefer to run the salt-master as a daemon, use this command:
# salt-master -d
# pip install git+https://github.com/saltstack/[email protected]
# salt --version
salt 2017.7.0-210-gc89cd2a (Nitrogen)
the salt-minion is configured via the minion configuration file.
By default, the salt-minion configuration is /etc/salt/minion
.
192.168.233.17
is the master ip address.
# more /etc/salt/minion
master: 192.168.233.17
id: minion_1
to start it with a debug log level, use this command:
# salt-minion -l debug
if you prefer to run the salt-minion as a daemon, use this command:
# salt-minion -d
# salt-key -L
Accepted Keys:
Denied Keys:
Unaccepted Keys:
minion_1
Rejected Keys:
# salt-key -a minion_1 -y
The following keys are going to be accepted:
Unaccepted Keys:
minion_1
Key for minion minion_1 accepted.
# salt-key -L
Accepted Keys:
minion_1
Denied Keys:
Unaccepted Keys:
Rejected Keys:
# salt --help
# sudo salt "minion_1" sys.doc test.ping
test.ping:
Used to make sure the minion is up and responding. Not an ICMP ping.
Returns ``True``.
CLI Example:
salt '*' test.ping
This command also returns the documentation:
# sudo salt "minion_1" test.ping -d
test.ping:
Used to make sure the minion is up and responding. Not an ICMP ping.
Returns ``True``.
CLI Example:
salt '*' test.ping
# sudo salt "minion_1" test.ping
minion_1:
True
This command also displays the job id:
# sudo salt "minion_1" test.ping -v
Executing job with jid 20170626143114314899
-------------------------------------------
minion_1:
True
# salt "minion_1" cmd.run "pwd"
minion_1:
/home/ksator
# sudo salt "minion_1" sys.doc disk
# sudo salt "minion_1" sys.doc disk.usage
disk.usage:
Return usage information for volumes mounted on this minion
CLI Example:
salt '*' disk.usage
# sudo salt "minion_1" disk.usage
on the master:
# sudo salt "minion_1" file.touch "/tmp/test.txt"
minion_1:
True
# sudo salt "minion_1" file.write "/tmp/test.txt" "hello"
minion_1:
Wrote 1 lines to "/tmp/test.txt"
on the minion:
# more /tmp/test.txt
hello