Advertisement
Guest User

Untitled

a guest
Apr 9th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.41 KB | None | 0 0
  1. _grains/map.jinja:
  2. # Using the hard coded from the salt-key name grain, grains['id'], for security
  3. {% set host_text, domain_text = salt['grains.get']('id').partition('.')[::2] %}
  4.  
  5. {% set subdomain = salt['grains.get']('id').partition('.')[2].partition('.')[2] %}
  6.  
  7. {% set host_list = host_text.split("-") %}
  8. {% set domain_list = domain_text.split(".") %}
  9.  
  10. {% set host_items_count = host_list|length %}
  11. {% set domain_items_count = domain_list|length %}
  12.  
  13. {% set subnet = salt['grains.get']('subnet_short') %}
  14.  
  15. # Fallback plan
  16. {% set component = host_list[0] %}
  17. {% set cluster = '' %}
  18. {% set role = '' %}
  19. {% set host_id = '' %}
  20. {% set host_combo = host_list[0] %}
  21.  
  22. {% if host_items_count == 2 %}
  23. {% set component = host_list[0] %}
  24. {% set cluster = '' %}
  25. {% set role = '' %}
  26. {% set host_id = host_list[1] %}
  27. {% set host_combo = host_list[0] %}
  28. {% elif host_items_count == 3 %}
  29. {% set component = host_list[0] %}
  30. {% set cluster = host_list[1] %}
  31. {% set role = '' %}
  32. {% set host_id = host_list[2] %}
  33. {% set host_combo = host_list[0] + '-' + host_list[1] %}
  34. {% elif host_items_count == 4 %}
  35. {% set component = host_list[0] %}
  36. {% set cluster = host_list[1] %}
  37. {% set role = host_list[2] %}
  38. {% set host_id = host_list[3] %}
  39. {% set host_combo = host_list[0] + '-' + host_list[1] + '-' + host_list[2] %}
  40. {% elif host_items_count == 5 %}
  41. {% set component = host_list[0] %}
  42. {% set cluster = host_list[1] %}
  43. {% set role = host_list[2] %}
  44. {% set codename = host_list[3] %}
  45. {% set host_id = host_list[4] %}
  46. {% set host_combo = host_list[0] + '-' + host_list[1] + '-' + host_list[2] %}
  47. {% endif %}
  48.  
  49. {% if domain_items_count >= 5 %}
  50. {% set env = domain_list[0] %}
  51. {% set region = domain_list[1] %}
  52. {% set provider = domain_list[2] %}
  53. {% endif %}
  54.  
  55. {% set component_cluster = component + '-' + cluster %}
  56. {% set component_role = component + '-' + role %}
  57. {% set component_cluster_role = component + '-' + cluster + '-' + role %}
  58. {% set component_cluster_env = component + '-' + cluster + '-' + env %}
  59. {% set component_cluster_env_region = component + '-' + cluster + '-' + env + '-' + region %}
  60. {% set cluster_env_region = cluster + '-' + env + '-' + region %}
  61.  
  62.  
  63. pillars/top.sls:
  64. {% import '_grains/map.jinja' as grain %}
  65.  
  66. base:
  67. '*':
  68. - accounts
  69. {% if grain.component == 'lb' and grain.account == 'development' %}
  70. - letsencrypt.{{ grain.account }}
  71. {% endif %}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement