Saltstack--grains

Source: Internet
Author: User
Tags 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, and so on. Using Commands
Salt ' client.aming.com ' grains.ls lists all grains project names
Salt ' client.aming.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.
grains can do configuration management.

Custom Grains

vim/etc/salt/minion
Add or change:
Grains:
role:
-Nginx
env:
-Test
or

Vim/etc/salt/grains //client editor

Add:
Role:nginx
env:test

Restart Minion Service
Get Grains:
Salt ' * ' grains.item role env
Salt ' client.aming.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 '


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.