GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Using Attributes Using Attributes
Mason J. Katz edited this page
"Attributes" are key/value pairs stored in the database that allow users to:
Attributes are used in all facets of cluster management and are persistent across install/reinstall of a single or many servers. Attributes are also easy to add, set, and remove on the command line. By default, Stacki comes with a set of attributes that help direct the base installation of a server. There are three levels on which an attribute can be defined. The order is global -> environment -> os -> appliance -> host.
This leaves us with a custom, per-server list of attributes that will be used primarily for generating installation, but also for classification. If you have set a global attribute default to "True" and you've set the same attribute for an individual host to be "True," then during installation, when that attribute is called, it will evaluate to "False." This allows us to program our cluster rather than keeping multiple files around for different scenarios. We can program different configuration based on a defined attribute. To see what attributes you have, use the "stack list command." Shows attributes defined at the Global level. An initial frontend installation will show you the attributes Stacki uses as part of the default installation. Shows the list of appliance defined attrs. An attribute list is concatenated from Global + Appliance + Host. With the layer below overwriting the layer above if both layers define the same attribute. Shows the attributes for a given host. An attribute list is concatenated from Global + Appliance + Host. With the layer below overwriting the layer if both layers define the same attribute. Global:
Single host:
This is actually fairly obvious. Global:
Appliance:
Host:
The real power of attributes comes when using them in carts. Attributes can be used for variable substitution and used in conditionals. There are more details in the Carts section of the documentation, but I'll give an example here. In a kickstart/autoyast/preseed file any attribute's key can be called by using an xml entity format which is Let's look at the resolv.xml file for an example. There is this bit of code snippet: The stack:file tag says to put the following stuff in /etc/hosts on the installing machine (e.g. backend-0-0) The 10.5.255.254 backend-0-0.local backend-0-0 So my file on the backend will look like this: Any attribute key can be used in an XML entity structure to call the value of that key. Attributes can also be to fire code if a condition is met. Take for example adding a prometheus server for monitoring to a cluster. I have created an attribute call "prometheus.firewall." I want to use it to add firewall rules to the host serving as my Prometheus server. So I define the attribute: But host backend-0-2 is my firewall so I'll set it to "True." Now when backend-0-2 installs, it will run the following commands: But no other machine will. In this way, you can have multiple configurations for a service in one cart file, dependent on attributes you have set. One thing I should mention: the 'stack:cond=' structure is python-esque in implementation so you can also use lists/and/or/not on that right side: These are all snipped: List: And: Or: If you are defining lots of attributes for a particular application, then it's easier to pack these into an attribute file. This is an example of what happens for the stacki-kubernetes pallet. It's large, but will give you a good idea of what's possible. In reality the csv file looks like this: Let's unpack it a bit: The header line requires "target" followed by all the keys, comma delimited. The next lines state which "target" (global,appliance, or host) a value should be set for. You'll note, the global line has a value for every key. This is the default value of the key. The individual hosts, change the default value. It's easier to define a global value that will be common, and change the exceptions at the host or appliance level. This attribute file, contains no appliance level targets. Load it: Output: Now every attribute we have defined can be used for variable substitution or used as a conditional to implement scripts and files in a cart. Using attribute files is a Stacki best practice, they're easier to manage and communicate with other members of your infrastructure team. Checkout our Google Group or our Slack Team for any support or other questions. Want to contribute to this Wiki? Fork it and send a pull request.
Clone this wiki locally |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |