saltstack命令和端口介绍

运维自动化应该是这几年比较热的名字之一,自动化工具用的比较多的有puppt,ansible,saltstack。当然很多人会选择ansible时候会说salt不支持ssh,需要客户端,其实salt也有salt-ssh模块。在此推荐salt书给需要学习的同学学习。《saltstack运维实战》后继文章大部分会以这书内容+赵班长视频+个人实战组合起来给大家展示。

|

端口:

Salt master启动后默认会监听两个端口:
4505(publish_port)—Salt Master pub接口 提供远程执行命令发送功能
4506(ret_port)—Salt Master Ret接口 支持认证、文件服务、结果收集等功能

Centos6.x开启防火墙:

-A INPUT -m state –state new -m tcp -p tcp –dport 4505 -j ACCEPT
-A INPUT -m state –state new -m tcp -p tcp –dport 4506 -j ACCEPT

命令:

对于很多minion情况下,可以在/etc/salt/master增加:
auto_accept:True
[root@localhost ~]# salt “*” test.ping 检查minion是否存活
192.168.1.135:
True
[root@localhost ~]# salt –help
Usage: salt [options] ‘ [arguments]

…..省略….
-G, –grain Instead of using shell globs to evaluate the target
use a grain value to identify targets, the syntax for
the target is the grain key followed by a
globexpression: “os:Arch*”
-N, –nodegroup Instead of using shell globs to evaluate the target
use one of the predefined nodegroups to identify a
list of targets.
–out=OUTPUT, –output=OUTPUT
Print the output from the ‘salt’ command using the
specified outputter. The builtins are ‘key’, ‘yaml’,
‘overstatestage’, ‘txt’, ‘newline_values_only’,
‘no_return’, ‘raw’, ‘virt_query’, ‘compact’, ‘json’,
‘highstate’, ‘nested’, ‘quiet’, ‘pprint’.

sys.list_functions查看模块包含哪些函数

[root@localhost ~]# salt “192.168.1.135” sys.list_functions user
192.168.1.135:

- user.add
- user.chfullname
- user.chgid
- user.chgroups
- user.chhome
- user.chhomephone
- user.chloginclass
- user.chroomnumber
- user.chshell
- user.chuid
- user.chworkphone
- user.delete
- user.get_loginclass
- user.getent
- user.info
- user.list_groups
- user.list_users
- user.rename

Comments

2017-03-01