Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Using the hard coded from the salt-key name grain, grains['id'], for security
- {% set host_text, domain_text = salt['grains.get']('id').partition('.')[::2] %}
- {% set subdomain = salt['grains.get']('id').partition('.')[2].partition('.')[2] %}
- {% set host_list = host_text.split("-") %}
- {% set domain_list = domain_text.split(".") %}
- {% set host_items_count = host_list|length %}
- # Slicing the hostname
- {% if host_items_count == 2 %}
- {% set component = host_list[0] %}
- {% set role = '' %}
- {% set host_id = host_list[1] %}
- {% set host_combo = host_list[0] %}
- {% elif host_items_count == 3 %}
- {% set component = host_list[0] %}
- {% set cluster = host_list[1] %}
- {% set role = '' %}
- {% set host_id = host_list[2] %}
- {% set host_combo = host_list[0] + '-' + host_list[1] %}
- {% elif host_items_count == 4 %}
- {% set component = host_list[0] %}
- {% set cluster = host_list[1] %}
- {% set role = host_list[2] %}
- {% set host_id = host_list[3] %}
- {% set host_combo = host_list[0] + '-' + host_list[1] + '-' + host_list[2] %}
- {% elif host_items_count == 5 %}
- {% set component = host_list[0] %}
- {% set cluster = host_list[1] %}
- {% set role = host_list[2] %}
- {% set codename = host_list[3] %}
- {% set host_id = host_list[4] %}
- {% set host_combo = host_list[0] + '-' + host_list[1] + '-' + host_list[2] %}
- {% endif %}
- # Slicing the domain
- {% set domain_items_count = domain_list|length %}
- {% if domain_items_count >= 5 %}
- {% set env = domain_list[0] %}
- {% set region = domain_list[1] %}
- {% set provider = domain_list[2] %}
- {% set root_domain = ".".join(domain_list[3:]) %}
- {% endif %}
- {% if root_domain == 'fetchcore-developers.com' %}
- {% set account = 'development' %}
- {% elif root_domain == 'fetchcore-cloud.com' %}
- {% set account = 'production' %}
- {% endif %}
- # Additional combinations
- {% set component_cluster = component + '-' + cluster %}
- {% set component_role = component + '-' + role %}
- {% set component_cluster_role = component + '-' + cluster + '-' + role %}
- {% set component_cluster_env = component + '-' + cluster + '-' + env %}
- {% set component_cluster_env_region = component + '-' + cluster + '-' + env + '-' + region %}
- {% set cluster_env_region = cluster + '-' + env + '-' + region %}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement