2.3-saltstack Grains

Source: Internet
Author: User
Tags custom name nginx server saltstack

Grains #收集设备的所有信息

Grains is a collection of information that is collected at Minion startup, such as the operating system type, network card IP, kernel version, CPU architecture, and so on.

Using commands

Salt ' client.wyp.com ' grains.ls lists all grains project names

Salt ' client.wyp.com ' grains.items lists all grains items and values

Grains information is not dynamic and is not always changed, it is only collected at minion startup.

We can do configuration management according to some information collected by grains.

Grains supports custom information.


Custom Grains

On the client:

Vim/etc/salt/minion

Add or change:

Grains

Role

-Nginx

Env:

-Test

Or

Vim/etc/salt/grains

Add to:

Role:nginx #注意空格, preceded by a custom name, followed by a value.

Env:test


Restart Minion Service

To get grains on the server:

Salt ' * ' grains.item role env

Salt ' client.wyp.com ' grains.get role


Grains is actually very handy when executing commands remotely. We can follow some of the grains's indicators to operate. For example, the grains role of all Web servers is set to Nginx, so that we can batch to the Nginx server operation:

Salt-g role:nginx cmd.run ' hostname '

Salt-g os:centos cmd.run ' hostname '


2.3-saltstack Grains

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.