09 Jan 2020
07:13 AM
- last edited on
28 Sep 2022
02:41 AM
by
MaciejNeumann
I have a problem with automatically applied tags. I guess it's a simple question, and yet I can't figure it out. We have a special name convention for our server names. The second digit of the host name means the stage in which the server is located (production, pre-procurement, etc.). Is it possible to create an automatically applied tag rule based on the hostname, depending on the value of the second digit of the host?
Example hostname: S45002134A (second character "4" means pre-production)
To create the rule:
- Rule applies to: "hosts"
- Condition: "Hostname" "begins with" (or "contains")
What needs to be entered in the field? I need kind of a placeholder for the first digit because the it changes based on other conditions.
Solved! Go to Solution.
I would try "contains regex" with ".4" as your condition. You can set the "optional tag value" to "pre-production" for this example and replicate the rule for other environments.
Rule applies to: "hosts"
Condition: "Host name" "contains regex"
Value: ^.{1}[4]
This might also work. It should match the second character of a string depending on what is in the square brackets.
Thanks for your help. It looks like i have to read more about regex 🙂