Grains
Was ist unter der Oberfläche eines Systems?
Wie sieht es unter der Oberfläche aus?
Salt comes with an interface to derive information about the underlying system. This is called the grains interface, because it presents salt with grains of information. Grains are collected for the operating system, domain name, IP address, kernel, OS type, memory, and many other system properties.
salt '*' grains.items
salt '*' grains.fetch roles
salt '*' grains.fetch ipv4
salt '*' grains.fetch osfinger
Adressieren Sie Minions über Grains
Windows oder Linux?
salt -G 'kernel:linux' test.ping
salt -G 'Os:Windows' test.ping
salt -G 'osfinger:Ubuntu-18.04' test.ping
Subnetze ansprechen
salt -G 'ip_interfaces:eth0:10.8.178.23' test.ping
salt -G 'ipv4:10.8.178.*' test.ping
Mehrere Grains zum Filtern verwenden
salt -C 'G@ipv4:10.8.178.* or G@ipv4:192.168.*' test.ping
salt -C 'G@ipv4:172.* and ( G@kernel:windows or G@kernel:linux )' test.ping
📖 https://docs.saltproject.io/en/latest/topics/targeting/compound.html
Eigene Grains setzen
grains:
customer: kramm
city: berlin
contact:
- phone: 030 09876
- street: bla
Grains kann man auch vom Master den Minions "zuweisen":
salt '<SOME_MINION>' grains.set role web
salt '<SOME_MINION>' grains.set roles [web,database]
salt 'delia' grains.set 'apps:myApp' '{port: 2209}'
salt delia grains.set test \
"{'location': {'city':'Essen', 'country':'Germany'}, 'newkey':'value'}" \
force=True
Beachten Sie, dass mit Sie mit grains.set
vorhandene Grains ggf. überschreiben. Sie können auch grains.append
verwenden.
Grains, welche Sie mit dem zuvor genannten Befehl setzen, werden vom Minion in die Datei /etc/salt/grains
gespeichert. Sollte eine weitere Grains-Konfigurationsdatei in /etc/salt/minion.d/
existieren, hat diese Vorrang und die per grains.set
oder grains.append
gesetzten Grains werden ignoriert.
📖 Mehr Informationen in der Projektdokumentation.
Last updated