MENU

saltstack 远程执行 2. 模块

January 1, 2018 • Read: 3990 • 17年实战

官方所有模板

>https://docs.saltstack.com/en/latest/ref/modules/all/index.html#all-salt-modules

常用模块

  • cmd
  • service
  • network

cmd 模块

salt '*'  cmd.run 'uptime'
#执行系统命令行

service 模块

salt 'Test1' service.get_all

查看主机安装的服务

salt 'Test1' service.start httpd

开机

salt 'Test1' service.stop httpd

关机

salt 'Test1' service.reload httpd

重载配置

salt 'Test1' service.status httpd

查看服务状态

salt 'Test1' service.available sshd

服务运行则返回True

salt 'Test1' service.missing sshd

服务运行则返回False

network

salt '*' network.active_tcp
#返回活动的tcp连接
salt '*' network.arp
#返回arp
salt '*' network.connect  103.44.145.131 21
salt '*' network.connect archlinux.org 80 timeout=3 family=ipv4
salt '*' network.connect google-public-dns-a.google.com port=53 proto=udp timeout=3
#测试端口连通性
salt '*' network.dig archlinux.org
#dns检测
salt '*' network.get_hostname
#获取当前主机名
salt '*' network.interface eno16777736
#获取网卡配置信息
salt '*' network.interfaces
#获取网卡所有信息

兼总条贯 知至知终

最后编辑于: April 2, 2018