Running a masterless salt-minion lets you use Salt's configuration management for a single machine without calling out to a Salt master on another machine.
Since the Salt minion contains such extensive functionality it can be useful to run it standalone. A standalone minion can be used to do a number of things:
设立一个master server通过States (Salting a Salt Master)
在任何操作系统上, 只要有Bourne shell, salt-bootstrap 脚本就可以一步步的使用Salt简单的创建一台服务器:
curl -L https://bootstrap.saltstack.com -o install_salt.sh sudo sh install_salt.sh
To instruct the minion to not look for a master, the
configuration option needs to be set in the minion configuration file.
By default the
file_client is set to
remote so that the
minion gathers file server and pillar data from the salt master.
When setting the
file_client option to
minion is configured to not gather this data from the master.
Now the salt minion will not look for a master and will assume that the local system has all of the file and pillar resources.
When running Salt in masterless mode, do not run the salt-minion daemon. Otherwise, it will attempt to connect to a master and fail. The salt-call command stands on its own and does not need the salt-minion daemon.
安装成功salt-minion后, 接下来将创建一个state树, 用于存储构成该minion状态的SLS文件.
For a complete explanation on Salt States, see the tutorial.
base: '*': - webserver
apache: # ID declaration pkg: # state declaration - installed # function declaration
The apache package has different names on different platforms, for instance on Debian/Ubuntu it is apache2, on Fedora/RHEL it is httpd and on Arch it is apache
The only thing left is to provision our minion using salt-call and the highstate command.
The salt-call command is used to run module functions locally on a minion instead of executing them from the master. Normally the salt-call command checks into the master to retrieve file server and pillar data, but when running standalone salt-call needs to be instructed to not check the master for this data:
salt-call --local state.highstate
--local 标签告诉salt-minion在本地文件系统上寻找state tree, 而不是去连接Salt Master.
salt-call --local state.highstate -l debug
top.sls 文件, 确认其属于
* glob匹配组, 然后
webserver.sls 文件, 发现需要运行安装Apache包的
The minion should now have Apache installed, and the next step is to begin learning how to write more complex states.