Docs/SaltStack/基础知识.md
2022-10-18 16:59:37 +08:00

48 lines
No EOL
1.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

```
saltstack通过在客户端的minion执行服务器端发送的命令
1、 Globsalt默认的target类型使用shell的通配符来指定一个或多个Minion ID
# salt \* test.ping 或 salt * test.ping
2、pcre兼容正则表达式
# salt E ^[m|M]in.[e|o|u]n$ test.ping
3、Subnet(通过指定一个IPv4地址或一个CIDR的IPv4子网)
# salt S 192.168.0.42 test.ping
# salt s 192.168.0.0/16 test.ping
4、Grains(salt可以通过操作系统、CPU架构及自定义信息等机器特征进行target Minion)
# salt G os:Ubuntu test.ping
# Salt G os_family:Debian test.ping
5、pillarsalt支持通过pillar数据进行匹配
# Salt I my_val:my_val test.ping
6、混合compound)
# Salt C web* or G@os:Arch test.ping
7、节点组Nodegroup
节点组需要事先定义,配置方法如下:
# vim /etc/salt/master
nodegroups:
node: L@node1,node2
# salt -N node test.ping
salt-key用于证书管理
salt 'slave' sys.doc grains # 查看grains的命令用法
salt 'slave' grains.items # 列出主机所有静态信息
salt 'slave' grains.ls # 列出所有grains方法
```