官术网_书友最值得收藏!

Configuring nodegroups

A feature that makes Salt very efficient is its ability to configure nodegroups. They are groups of hosts that we can configure based on various system properties and use the group name to target minions. In this recipe, you will learn how to configure nodegroups.

How to do it...

  1. Edit the /etc/salt/master file on the Salt master and uncomment the key nodegroups. Edit the lines following the nodegroups key so that the entire nodegroups configuration looks as follows:
    nodegroups:
      stgdb: 'G@environment:staging and G@server_type:db'
      dc1devapp: 'G@location:dc1 and G@environment:development and G@server_type:app'
      prodmon: 'L@prddc1mon01,prddc2mon03,prddc3mon10'
  2. Restart the salt-master daemon for the changes to take place.

How it works...

In this recipe, we demonstrated how to configure nodegroups in various ways.

The nodegroups key in the master configuration file needs to be uncommented and all entries under it are identified as configured nodegroups.

The first line is configured as follows:

stgdb: 'G@environment:staging and G@server_type:db'

This states that the group name is stgdb, and it includes all nodes having the value of the environment grain as staging and the value of the server_type grain as db. The G@ parameter is used to specify grains and their values.

The second line defines a nodegroup called dc1devapp that has a similar configuration to the first line with an extra grain called location.

The third line defines a nodegroup called prodmon and includes a list of hosts as mentioned in the configuration. The L@ parameter is used to specify a comma-separated list of minions.

These nodegroups can now be used to target minions.

See also

  • The Configuring the Salt environment and pillar paths recipe, in Chapter 1, Salt Architecture and Components, to learn more about environments
  • The Using grains in states recipe, to know more about configuring grains
  • The Targeting minions recipe, to learn how to target minions using nodegroups
主站蜘蛛池模板: 万山特区| 获嘉县| 孟村| 桐乡市| 禹州市| 海门市| 乌海市| 融水| 湘潭县| 昌图县| 清涧县| 洪湖市| 秦皇岛市| 嵊泗县| 金阳县| 巨鹿县| 平罗县| 伊春市| 东方市| 马尔康县| 宜川县| 哈巴河县| 永丰县| 曲靖市| 昭通市| 昌平区| 沭阳县| 吴川市| 和龙市| 繁昌县| 西乌珠穆沁旗| 砚山县| 遂平县| 明水县| 通化市| 德令哈市| 开江县| 枝江市| 二连浩特市| 岗巴县| 孝感市|