SaltStack远程执行-模块

  上一篇:SaltStack数据系统-Pillar

  执行模块

salt 'linux-node2.example.com' service.status sshd

  其中service是模块名称status是方法sshd是参数

  network模块

  network.active_tcp返回所有TCP链接

salt 'linux-node2.example.com' network.active_tcp

  network.arp返回arp表

salt 'linux-node2.example.com' network.arp

  network.connect测试端口是否通(类似于telnet)

salt 'linux-node2.example.com' network.connect 192.168.56.12 22

  get_hostname获取主机名

salt '*' network.get_hostname

  service模块

  service.available判断服务是否在运行

salt '*' service.available sshd

  service.get获取所有在运行的服务

salt '*' service.get_all

  service.reload重启服务,类似于cmd.run 

salt '*' service.reload sshd

  针对跨平台管理有作用

  service.status获取服务状态

salt '*' service.status sshd

  service.stop停止服务

salt '*' service.stop sshd

  

  state状态模块

  state.show_highstate查看机器的高级状态

salt '*' state.show_highstate

  state.show_top查看有哪些sls

salt '*' state.show_top

  

  文件拷贝模块(单独出一个命令)

salt-cp '*' /etc/resolv.conf /tmp/

  PS:这个命令非常有用

  

原文地址:https://www.cnblogs.com/minseo/p/8776077.html