saltstack常用命令

1. 测试连通性

salt  '*'  test.ping
# '*'表示所有目标机器 test.ping 只是模块里的一个功能,用来测试连通性

2. 常用命令结构

salt  [options]  <目标机>  <功能>  [arguments]

# 例如:

#对机器node1使用w命令

test 'node1' cmd.run 'w'

3. salt-key 密钥管理,通常在master上执行

salt-key [options]
salt-key -L              ##查看所有minion-key
salt-key -a <key-name>   ##接受某个minion-key
salt-key -d <key-name>   ##删除某个minion-key
salt-key -A              ##接受所有的minion-key
salt-key -D              ##删除所有的minion-key

4. salt-call

# 该命令通常在minion上执行,minion自己执行可执行模块,不是通过master下发job
salt-call [options] <function> [arguments]
salt-call test.ping           ##自己执行test.ping命令
salt-call cmd.run  'ifconfig'  ##自己执行cmd.run函数

5. salt-cp
# 分发文件到minion上,不支持目录分发,通常在master运行
salt-cp [options] '<target>' SOURCE DEST
salt-cp '*' testfile.html /tmp
salt-cp 'node*' /opt/index.html /tmp/a.html


# 查看模块文档
salt '*' sys.doc pkg           #查看pkg模块文档 
# salt内置的执行模块列表
http://docs.saltstack.cn/ref/modules/all/index.html


 

posted @ 2023-03-29 10:29  羊脂玉净瓶  阅读(89)  评论(0)    收藏  举报