Saltstack Road--saltstack Use command (2)

Source: Internet
Author: User
Tags saltstack

/etc/salt/master configuration file Description
CentOS-6.8405 # example:406 # file_roots:407 # base: # #基础环境 #base default exists. Cannot be modified (modify config file, must restart!) 408 #-/srv/salt/# #此目录需要创建 (Root path) 409 # dev: # #开发环境410 #-/srv/salt/dev/services411 #-/SR v/salt/dev/states412 # prod: # #生产环境413 #-/srv/salt/prod/services414 #-/srv/salt/prod/states CentOS -7 is supposed to be 453-465.


Mini configuration File Description
[[email protected] ~]# egrep-v "^#|^$"/etc/salt/minionmaster:172.16.1.61 = "Note the following spaces (hereinafter) Id:backup comments: Vim/etc/salt/min Ionmaster:m01

#16行 Master: The IP or hostname of the host: The following must have 1 spaces if you want to fill in the host name needs to have DNS resolution

Id:nfs01

#101行id: Subordinate name, can not be configured, default to use host name, will generate a minion_id file in/etc/salt/, view this file display native hostname

#如果需要修改主机名, this file must be deleted. Because the salt reads the file first when it is read minion_id

The host name cannot use an underscore


1. Remote execution
[[email protected] ~]# Salt ' web01 ' test.ping #salt ' * ' test.pingweb01:True


#salt command

# * for the goal

#test is a module command (method)

#ping是test的一个参数 test that all hosts are alive--master communication with Minion is not the same as ping IP. Ping to ICMP


1.1. Run the shell command

Cmd.run cannot perform interactive commands, such as vim,ssh

[[email protected] ~]# salt  ' * '  cmd.run  ' df -h ' web02:    filesystem      size  used  avail  use%  mounted on    /dev/sda2      19g   1.6g   17G  9%   /   tmpfs         491m  12k  491m  1%   /dev/shm   /dev/ sda1      190m  33m  147m  19%  / bootweb01:   filesystem      size  used   avail  use% mounted on   /dev/sda2      19g     1.5G 7G   9%  /   tmpfs         491m   12k  491m  1%  /dev/shm   /dev/sda1       190m   33m  147m  19% /boot


1.2. Copy files using salt
## salt-cp  ' host '   source file Destination Management machine (M01): [[Email protected] ~]# mkdir -p /server /scripts[[email protected] ~]# cd /server/scripts/[[email protected] scripts]#  echo "Test" >test.txt[[email protected] scripts]# salt-cp  ' * '  /server/scripts/ test.txt /server/{' web01 ':  {'/server/test.txt ': true},  ' web02 ': {'/server/test.txt ':  True},} Managed by Machine (WEB01):[[email protected] ~]# tree /server//server/├── scripts└──  test.txt 1 directory, 1 file[[email protected] ~]#[[email protected]  scripts]# touch 888.txt[[email protected] scripts]# salt-cp  ' Web01 '  888.txt /server/{' web01 ':  {'/server/888.txt ':  true}}[[email protected] scripts] #查证 [[email  Protected] ~]# ls /server/666.txt 888.txt  scripts  test.txt[[email  protected] ~]# 






This article comes from "lone man quick!" The walkers are far away! "Blog, be sure to keep this provenance http://syaving.blog.51cto.com/5614476/1869719

Saltstack Road--saltstack Use command (2)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.