Saltstack Official Salt Formula
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

cloud.sls 2.5KB

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