Advertisement
Guest User

Untitled

a guest
May 24th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.73 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. {% if domain_list[-1] == 'consul' %}
  17. {% set component = host_list[0] %}
  18. {% set cluster = '' %}
  19. {% set role = host_list[0] %}
  20. {% set host_id = domain_list[0] %}
  21. {% set env = domain_list[1] %}
  22. {% set region = domain_list[3] %}
  23. {% else %}
  24. {% set component = host_list[0] %}
  25. {% set cluster = '' %}
  26. {% set role = '' %}
  27. {% set host_id = '' %}
  28. {% set host_combo = host_list[0] %}
  29.  
  30. {% if host_items_count == 2 %}
  31. {% set component = host_list[0] %}
  32. {% set cluster = '' %}
  33. {% set role = '' %}
  34. {% set host_id = host_list[1] %}
  35. {% set host_combo = host_list[0] %}
  36. {% elif host_items_count == 3 %}
  37. {% set component = host_list[0] %}
  38. {% set cluster = host_list[1] %}
  39. {% set role = '' %}
  40. {% set host_id = host_list[2] %}
  41. {% set host_combo = host_list[0] + '-' + host_list[1] %}
  42. {% elif host_items_count == 4 %}
  43. {% set component = host_list[0] %}
  44. {% set cluster = host_list[1] %}
  45. {% set role = host_list[2] %}
  46. {% set host_id = host_list[3] %}
  47. {% set host_combo = host_list[0] + '-' + host_list[1] + '-' + host_list[2] %}
  48. {% elif host_items_count == 5 %}
  49. {% set component = host_list[0] %}
  50. {% set cluster = host_list[1] %}
  51. {% set role = host_list[2] %}
  52. {% set codename = host_list[3] %}
  53. {% set host_id = host_list[4] %}
  54. {% set host_combo = host_list[0] + '-' + host_list[1] + '-' + host_list[2] %}
  55. {% endif %}
  56.  
  57. {% if domain_items_count >= 5 %}
  58. {% set env = domain_list[0] %}
  59. {% set region = domain_list[1] %}
  60. {% set provider = domain_list[2] %}
  61. {% endif %}
  62.  
  63. {% endif %}
  64.  
  65. {% set component_cluster = component + '-' + cluster %}
  66. {% set component_role = component + '-' + role %}
  67. {% set component_cluster_role = component + '-' + cluster + '-' + role %}
  68. {% set component_cluster_env = component + '-' + cluster + '-' + env %}
  69. {% set component_cluster_env_region = component + '-' + cluster + '-' + env + '-' + region %}
  70. {% set cluster_env_region = cluster + '-' + env + '-' + region %}
  71.  
  72. pillars/top.sls
  73. {% import '_grains/map.jinja' as grain %}
  74.  
  75. base:
  76. '*':
  77. - app_users
  78. - artifactory
  79. - global
  80. - accounts
  81. - saml
  82. - schedule
  83. {% if grain.account == 'development' %}
  84. - letsencrypt.{{ grain.account }}.common.aws
  85. {% endif %}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement