欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程资源 > 编程问答 >内容正文

编程问答

salt常用命令(一)

发布时间:2025/6/17 编程问答 39 豆豆
生活随笔 收集整理的这篇文章主要介绍了 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

总结

以上是生活随笔为你收集整理的salt常用命令(一)的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。