SaltStack远程执行详解

●目标(Targeting)
●模块(Module)
●返回(Returnners)
混合模式-C 选项
主机名设置参照:
redis-node1-redis03-idc04-soa.example.com(电商)
1.1模块介绍
[root@linux-node1 salt]# salt '*' service.available sshd
linux-node1.zhurui.com:
    True
linux-node2.zhurui.com:
    True
服务重载:
  1. [root@linux-node1 salt]# salt '*' service.reload httpd
  2. linux-node2.zhurui.com:
  3. True
  4. linux-node1.zhurui.com:
  5. True
服务状态:
  1. [root@linux-node1 salt]# salt '*' service.status httpd
  2. linux-node1.zhurui.com:
  3. True
  4. linux-node2.zhurui.com:
  5. True
  6. [root@linux-node1 salt]#
1.2network模块介绍
1.2.1返回tcp状态
  1. [root@linux-node1 salt]# salt '*' network.active_tcp
  2. linux-node2.zhurui.com:
  3. ----------
  4. 0:
  5. ----------
  6. local_addr:
  7. 0.0.0.0
  8. local_port:
  9. 2049
  10. remote_addr:
  11. 0.0.0.0
  12. remote_port:
  13. 0
  14. 1:
  15. ----------
  16. local_addr:
  17. 0.0.0.0
  18. local_port:
  19. 35682
  20. remote_addr:
  21. 0.0.0.0
  22. remote_port:
  23. 0
  24. 10:
  25. ----------
  26. local_addr:
  27. 192.168.0.16
  28. local_port:
  29. 48670
  30. remote_addr:
  31. 192.168.0.15
  32. remote_port:
  33. 4506
  34. 2:
  35. ----------
  36. local_addr:
  37. 0.0.0.0
  38. local_port:
  39. 875
  40. remote_addr:
  41. 0.0.0.0
  42. remote_port:
  43. 0
  44. 3:
  45. ----------
  46. local_addr:
  47. 0.0.0.0
  48. local_port:
  49. 111
  50. remote_addr:
  51. 0.0.0.0
  52. remote_port:
  53. 0
  54. 4:
  55. ----------
  56. local_addr:
  57. 0.0.0.0
  58. local_port:
  59. 51349
  60. remote_addr:
  61. 0.0.0.0
  62. remote_port:
  63. 0
  64. 5:
  65. ----------
  66. local_addr:
  67. 0.0.0.0
  68. local_port:
  69. 22
  70. remote_addr:
  71. 0.0.0.0
  72. remote_port:
  73. 0
  74. 6:
  75. ----------
  76. local_addr:
  77. 0.0.0.0
  78. local_port:
  79. 55993
  80. remote_addr:
  81. 0.0.0.0
  82. remote_port:
  83. 0
  84. 7:
  85. ----------
  86. local_addr:
  87. 0.0.0.0
  88. local_port:
  89. 58267
  90. remote_addr:
  91. 0.0.0.0
  92. remote_port:
  93. 0
  94. 8:
  95. ----------
  96. local_addr:
  97. 192.168.0.16
  98. local_port:
  99. 22
  100. remote_addr:
  101. 192.168.0.101
  102. remote_port:
  103. 49285
  104. 9:
  105. ----------
  106. local_addr:
  107. 192.168.0.16
  108. local_port:
  109. 59181
  110. remote_addr:
  111. 192.168.0.15
  112. remote_port:
  113. 4505
  114. linux-node1.zhurui.com:
  115. ----------
  116. 0:
  117. ----------
  118. local_addr:
  119. 0.0.0.0
  120. local_port:
  121. 58975
  122. remote_addr:
  123. 0.0.0.0
  124. remote_port:
  125. 0
  126. 1:
  127. ----------
  128. local_addr:
  129. 0.0.0.0
  130. local_port:
  131. 49856
  132. remote_addr:
  133. 0.0.0.0
  134. remote_port:
  135. 0
  136. 10:
  137. ----------
  138. local_addr:
  139. 0.0.0.0
  140. local_port:
  141. 4505
  142. remote_addr:
  143. 0.0.0.0
  144. remote_port:
  145. 0
  146. 11:
  147. ----------
  148. local_addr:
  149. 0.0.0.0
  150. local_port:
  151. 4506
  152. remote_addr:
  153. 0.0.0.0
  154. remote_port:
  155. 0
  156. 12:
  157. ----------
  158. local_addr:
  159. 192.168.0.15
  160. local_port:
  161. 4505
  162. remote_addr:
  163. 192.168.0.15
  164. remote_port:
  165. 51071
  166. 13:
  167. ----------
  168. local_addr:
  169. 192.168.0.15
  170. local_port:
  171. 4506
  172. remote_addr:
  173. 192.168.0.16
  174. remote_port:
  175. 48670
  176. 14:
  177. ----------
  178. local_addr:
  179. 192.168.0.15
  180. local_port:
  181. 4506
  182. remote_addr:
  183. 192.168.0.15
  184. remote_port:
  185. 33972
  186. 15:
  187. ----------
  188. local_addr:
  189. 192.168.0.15
  190. local_port:
  191. 22
  192. remote_addr:
  193. 192.168.0.101
  194. remote_port:
  195. 49268
  196. 16:
  197. ----------
  198. local_addr:
  199. 192.168.0.15
  200. local_port:
  201. 33972
  202. remote_addr:
  203. 192.168.0.15
  204. remote_port:
  205. 4506
  206. 17:
  207. ----------
  208. local_addr:
  209. 192.168.0.15
  210. local_port:
  211. 4505
  212. remote_addr:
  213. 192.168.0.16
  214. remote_port:
  215. 59181
  216. 18:
  217. ----------
  218. local_addr:
  219. 127.0.0.1
  220. local_port:
  221. 45016
  222. remote_addr:
  223. 127.0.0.1
  224. remote_port:
  225. 4506
  226. 19:
  227. ----------
  228. local_addr:
  229. 192.168.0.15
  230. local_port:
  231. 51071
  232. remote_addr:
  233. 192.168.0.15
  234. remote_port:
  235. 4505
  236. 2:
  237. ----------
  238. local_addr:
  239. 0.0.0.0
  240. local_port:
  241. 2049
  242. remote_addr:
  243. 0.0.0.0
  244. remote_port:
  245. 0
  246. 3:
  247. ----------
  248. local_addr:
  249. 0.0.0.0
  250. local_port:
  251. 44356
  252. remote_addr:
  253. 0.0.0.0
  254. remote_port:
  255. 0
  256. 4:
  257. ----------
  258. local_addr:
  259. 0.0.0.0
  260. local_port:
  261. 40808
  262. remote_addr:
  263. 0.0.0.0
  264. remote_port:
  265. 0
  266. 5:
  267. ----------
  268. local_addr:
  269. 0.0.0.0
  270. local_port:
  271. 11211
  272. remote_addr:
  273. 0.0.0.0
  274. remote_port:
  275. 0
1.2.1在master设置规则允许特定用户,可使用的特定方法
  1. [root@linux-node1 salt]# vim /etc/salt/master
245 client_acl:
246   zhurui1:
247     - test.ping
248     - network.
[root@linux-node1 salt]# /etc/init.d/salt-master restart
Stopping salt-master daemon:                               [  OK  ]
Starting salt-master daemon:                                 [  OK  ]
[root@linux-node1 salt]# useradd  zhurui1  ##创建用户,并且设置密码
[root@linux-node1 salt]# echo '123456'|passwd --stdin zhurui1
Changing password for user zhurui.
passwd: all authentication tokens updated successfully.
[root@linux-node1 salt]# 
[root@linux-node1 home]# chmod 777 /var/log/salt/master
[root@linux-node1 home]# su - zhurui1
[zhurui1@linux-node1 ~]$ salt '*' test.ping
linux-node2.zhurui.com:
    True
linux-node1.zhurui.com:
    True
[zhurui1@linux-node1 ~]$ 
截图如下:
运行其他模块跟方法会报错,没有权限
1.2.2 指定特定主机,在特定用户下允许的操作
  1. client_acl:
  2. zhurui1:
  3. - test.ping
  4. - network.*
  5. user01:
  6. - linux-node1*:
  7. - test.ping
[root@linux-node1 home]# /etc/init.d/salt-master restart
Stopping salt-master daemon:                               [  OK  ]
Starting salt-master daemon:                               [  OK  ]
[root@linux-node1 home]# su - user01
[user01@linux-node1 ~]$ salt '*' test.ping           
Failed to authenticate! This is most likely because this user is not permitted to execute commands, but there is a small possibility that a disk error occurred (check disk/inode usage).
[user01@linux-node1 ~]$ salt 'linux-node1*' test.ping 
linux-node1.zhurui.com:
    True
1.2.3 指定黑名单,禁止特定用户的操作
开启如下行:
 
 

2、自动化运维之SaltStack远程执行详解的更多相关文章

  1. ansible自动化运维详细教程及playbook详解

    前言 当下有许多的运维自动化工具( 配置管理 ),例如:Ansible.SaltStack.Puppet.Fabric 等. Ansible 一种集成 IT 系统的配置管理.应用部署.执行特定任务的开 ...

  2. 1、自动化运维之SaltStack实践

    自动化运维之SaltStack实践 1.1.环境 linux-node1(master服务端) 192.168.0.15 linux-node2(minion客户端) 192.168.0.16 1.2 ...

  3. 自动化运维之Saltstack

    第三十八课 自动化运维之Saltstack 目录 一.自动化运维介绍 二. saltstack安装 三. 启动saltstack服务 四. saltstack配置认证 五. saltstack远程执行 ...

  4. 自动化运维工具 SaltStack 搭建

    原文地址:https://www.ibm.com/developerworks/cn/opensource/os-devops-saltstack-in-cloud/index.html#N10072 ...

  5. 自动化运维工具SaltStack详细部署【转】

    ==========================================================================================一.基础介绍==== ...

  6. 自动化运维与Saltstack

    一.自动化运维介绍 1.自动化运维产生背景   传统的IT运维是将数据中心中的网络设备.服务器.数据库.中间件.存储.虚拟化.硬件等资源进行统一监控,当资源出现告警时,运维人员通过工具或者基于经验进行 ...

  7. 自动化运维之SaltStack实践

    自动化运维之SaltStack实践 1.1.环境 linux-node1(master服务端) 192.168.0.15 linux-node2(minion客户端) 192.168.0.16 1.2 ...

  8. saltstack自动化运维系列⑧SaltStack实践配置管理安装nginx-1.10.3

    saltstack自动化运维系列⑧SaltStack实践配置管理安装nginx-1.10.3 安装nginx-1.10.3.tar.gz # mkdir -p /srv/salt/prod/pkg / ...

  9. saltstack自动化运维系列⑦SaltStack实践配置管理安装zabbix

    saltstack自动化运维系列⑥SaltStack实践配置管理安装zabbix 1.添加管理zabbix的sls文件# vim /srv/salt/base/init/zabbix_agent.sl ...

随机推荐

  1. R 网络图 nodes,edges属性计算

    前面提到了用R画网络图,免不了要对网络图nodes和edges的特征做一些统计.分享下我的代码: ########## nodes edges的统计########### # ####nodes的度有 ...

  2. C#学习(一):委托和事件

    预备知识 在学习委托和事件之前,我们需要知道的是,很多程序都有一个共同的需求,即当一个特定的程序事件发生时,程序的其他部分可以得到该事件已经发生的通知. 而发布者/订阅者模式可以满足这种需求.简单来说 ...

  3. 实验效果展示(会声会影+FSCapture)

    第一步,视频录制: 利用屏幕录制软件(Eg:FSCapture,可设定矩形区域)录制信号采集过程,存储. 第二步,视频叠加制作 1)导入视频 2)主轨,复叠轨视频安插&时序调整 3)两个视频图 ...

  4. springboot数据库连接池使用策略

    springboot官方文档介绍数据库连接池的使用策略如下: Production database connections can also be auto-configured using a p ...

  5. 常用的TCP选项

    MSS选项:通知最大可接收量.发送SYN的TCP一端使用本选项通告对端它的最大分节大小(maximum segment size)即MSS,也就是它在本连接的每个TCP分节中愿意接受的最大数据量.发送 ...

  6. MySql常用两大存储引擎简介

    MyISAM存储引擎简介 MyISAM存储引擎的表在数据库中,每一个表都被存放为三个以表名命名的物理文件. 首先肯定会有任何存储引擎都不可缺少的存放表结构定义信息的.frm文件,另外还有.MYD和.M ...

  7. 在Python中用Request库模拟登录(三):Discuz论坛(未加密,有验证码,有隐藏验证)

    以Discuz的官方站为例.直接点击网页右上角的登录按钮,会弹出一个带验证码的登录窗口.输入验证码之后,会检查验证码是否正确.然后登录.首先,通过抓包分析,这些过程浏览器和服务器交换了哪些数据. 抓包 ...

  8. org.springframework.web.servlet.PageNotFound

    2017-07-11 16:36:13.489 WARN [http-nio-8032-exec-16]org.springframework.web.servlet.PageNotFound -Re ...

  9. CAP原理和BASE思想

    分布式领域CAP理论,Consistency(一致性), 数据一致更新,所有数据变动都是同步的Availability(可用性), 好的响应性能Partition tolerance(分区容错性) 可 ...

  10. aliyun TableStore相关操作汇总

    总结:这个东西本身可能技术还不成熟,使用的人少,有问题很验证解决 遇到的问题:(1)没有一个GUI工具,使用门槛高(2)查询的GetRange不方便,把查询出来的数据使用System.out.prin ...