salt常用命令(一)

查看模块包含哪些函数

salt 'node' sys.list_functions test

查看函数的用法

salt 'node' sys.doc test.echo 

使用模块中的函数

salt 'node' test.echo 'hello world'

查看命令执行的完整信息

salt 'node' --summary test.echo 'hello world'

输出详细信息

salt 'node' cmd.run_all 'echo hello world'

正则表达式

salt -E '*' test.ping

需要参数-E,来匹配正则

匹配指定主机

salt -L 'minion-one,minion-two,mnion-three' test.ping

匹配主机组

salt -N 'groupname' test.ping

grains文件 是 机器属性的静态数据,例如:服务器的系统版本、内存大小等.

列出所有Grains数据

salt 'minion-one' grains.items

查询某个grains数据

salt 'minion-one' grains. item os

-G参数对Grains数据进行匹配
匹配系统是centos的

salt -G 'os:CentOS' test.ping

自定义Grains

salt 'node' grains.setval cpu_num 8

复杂一些

salt 'node' grains.setval cpu_info '['intel','xenon','8']'

pillars 列出全部信息

salt 'node' pillars.items

安装包管理

pkg模块

文件管理模块

service

用户管理模块

user
原文地址:https://www.cnblogs.com/wspblog/p/6392202.html