Saltstack Official Salt Formula
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

101 lines
2.5KB

  1. {% from "salt/map.jinja" import salt_settings with context %}
  2. {% set cloudmaps = salt['pillar.get']('salt:cloud:maps', {}) -%}
  3. {% set cloudprofiles = salt['pillar.get']('salt:cloud:profiles', {}) -%}
  4. {% set cloudproviders = salt['pillar.get']('salt:cloud:providers', {}) -%}
  5. {%- if salt_settings.use_pip %}
  6. python-pip:
  7. pkg.installed
  8. salt-cloud-pip-packages:
  9. pip.installed:
  10. - pkgs:
  11. - apache-libcloud
  12. {%- if grains['os_family'] not in ['Debian', 'RedHat'] %}
  13. - crypto
  14. {%- endif %}
  15. - pycrypto
  16. - require:
  17. - pkg: python-pip
  18. {%- endif %}
  19. {% if salt_settings.install_packages %}
  20. salt-cloud:
  21. pkg.installed:
  22. - name: {{ salt_settings.salt_cloud }}
  23. {%- if salt_settings.use_pip %}
  24. - require:
  25. - pip: salt-cloud-pip-packages
  26. {%- endif %}
  27. {% endif %}
  28. {% for cert in pillar.get('salt_cloud_certs', {}) %}
  29. {% for type in ['pem'] %}
  30. cloud-cert-{{ cert }}-pem:
  31. file.managed:
  32. - name: {{ salt_settings.config_path }}/pki/cloud/{{ cert }}.pem
  33. - source: salt://{{ slspath }}/files/key
  34. - template: jinja
  35. - user: root
  36. - group:
  37. {%- if grains['kernel'] in ['FreeBSD', 'OpenBSD', 'NetBSD'] %}
  38. wheel
  39. {%- else %}
  40. root
  41. {%- endif %}
  42. - mode: 600
  43. - makedirs: True
  44. - defaults:
  45. key: {{ cert }}
  46. type: {{ type }}
  47. {% endfor %}
  48. {% endfor %}
  49. {%- for dir, templ_path in salt_settings.cloud.template_sources.items() %}
  50. salt-cloud-{{ dir }}:
  51. file.recurse:
  52. - name: {{ salt_settings.config_path }}/cloud.{{ dir }}.d
  53. - source: {{ templ_path }}
  54. - template: jinja
  55. - makedirs: True
  56. {%- endfor %}
  57. {% for key, value in cloudmaps.items() %}
  58. /etc/salt/cloud.maps.d/{{ key }}:
  59. file.managed:
  60. - contents: |
  61. {{ value|yaml(False) | indent(8) }}
  62. {% endfor %}
  63. {% for key, value in cloudprofiles.items() %}
  64. /etc/salt/cloud.profiles.d/{{ key }}:
  65. file.managed:
  66. - contents: |
  67. {{ value|yaml(False) | indent(8) }}
  68. {% endfor %}
  69. {% for key, value in cloudproviders.items() %}
  70. /etc/salt/cloud.providers.d/{{ key }}:
  71. file.managed:
  72. - contents: |
  73. {{ value|yaml(False) | indent(8) }}
  74. {% endfor %}
  75. salt-cloud-providers-permissions:
  76. file.directory:
  77. - name: {{ salt_settings.config_path }}/cloud.providers.d
  78. - user: root
  79. - group:
  80. {%- if grains['kernel'] in ['FreeBSD', 'OpenBSD', 'NetBSD'] %}
  81. wheel
  82. {%- else %}
  83. root
  84. {%- endif %}
  85. - file_mode: 600
  86. - dir_mode: 700
  87. - recurse:
  88. - user
  89. - group
  90. - mode