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.

97 line
2.3KB

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