Saltsack automatic operation and maintenance 2

Source: Internet
Author: User

1.SaltStack Data System

Grains: Stored on the minion side, collect information at startup, static data, and re-collect it when it restarts.

A. Application scenario: Information query,

[[email protected] salt]# Salt ' salt-master ' grains.ls         # show Ls[[email protected] salt]# salt ' salt-master ' Grains.item S    # Show all [[email protected] salt]# Salt ' salt-master ' grains.get FQDN  salt-master:    salt-master.xiao.com[[ Email protected] salt]# Salt ' salt-master ' grains.get server_idsalt-master:    894500124[[email protected] salt]# salt ' Salt-master ' grains.get ip_interfaces:eth0salt-master:    -192.168.2.12    -fe80::20c:29ff:fe99:4d5e

B. Matching Minion

[[email protected] salt]# salt-g os:centos cmd.run ' W ' salt-master:     05:26:01  up 1:07,  1 user,  load average:0.00, 0.00, 0.00    USER     TTY      from              [email protected]   IDLE   jcpu   PCPU    Root     pts/0    192.168.2.1      04:19    0.00s  0.80s  0.55s/usr/bin/pythonsalt-minion:     05:36:34 up  1:07,  1 user,  load average:0.00, 0.00, 0.00    User     TTY      from              [email Protected]   IDLE   jcpu   PCPU what    root     pts/0    192.168.2.1   04:30 25:21 0.15s  0.15s-bash

Custom Grains,

[[email protected] salt]# vim/etc/salt/minion   # Open Comment grains:89   roles:90     -webserver-     Memcach E[[email protected] salt]# salt-g ' roles:memcache ' cmd.run ' echo hehe '   # perform echo memcached on Hehesalt-master:
   hehe

or set up in Vim/etc/salt/grains

[[email protected] salt]# vim/etc/salt/grains        # Custom Create a grains nginxweb rule nginxweb:nginx~                                                                                              [[email protected] salt]#/etc/init.d/salt-minion restart[[email protected] salt]# salt-g nginxweb:nginx cmd.run ' W '  # Find minion matches to a machine with Nginxweb:nginx execute w command salt-master:     05:39:53 up  1:21,  1 user,  load average:0.08, 0.02, 0.01    USER     TTY      from              [email protected]   IDLE   jcpu   PCPU what    root     pts/0    192.168.2.1      04:19    1.00s  0.85s  0.53s/usr/bin/python[[email protected] salt]# vim/srv/ Salt/top.sls      # Build Advanced SLS Command base:  ' Nginxweb:nginx ':                                 # Associate the custom rule in grain above    -match:grain    -Apache [[email protected] salt]# Salt ' * ' state.hightstate  # Execute

Saltsack automatic operation and maintenance 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.