diff --git a/salt/cloud.sls b/salt/cloud.sls index bf66959..85d2423 100644 --- a/salt/cloud.sls +++ b/salt/cloud.sls @@ -1,27 +1,17 @@ {% from "salt/map.jinja" import salt_settings with context %} -{% set cloudmaps = salt['pillar.get']('salt:cloud:maps', {}) -%} -{% set cloudprofiles = salt['pillar.get']('salt:cloud:profiles', {}) -%} -{% set cloudproviders = salt['pillar.get']('salt:cloud:providers', {}) -%} - {%- if salt_settings.use_pip %} python-pip: pkg.installed -pycrypto: - pip.installed: - - require: - - pkg: python-pip - -{% if grains['os_family'] not in ['Debian', 'RedHat'] %} -crypto: - pip.installed: - - require: - - pkg: python-pip -{% endif %} - -apache-libcloud: +salt-cloud-pip-packages: pip.installed: + - pkgs: + - apache-libcloud + {%- if grains['os_family'] not in ['Debian', 'RedHat'] %} + - crypto + {%- endif %} + - pycrypto - require: - pkg: python-pip {%- endif %} @@ -32,11 +22,7 @@ salt-cloud: - name: {{ salt_settings.salt_cloud }} {%- if salt_settings.use_pip %} - require: - - pip: apache-libcloud - - pip: pycrypto - {% if grains['os_family'] not in ['Debian', 'RedHat'] %} - - pip: crypto - {% endif %} + - pip: salt-cloud-pip-packages {%- endif %} {% endif %} @@ -62,34 +48,27 @@ cloud-cert-{{ cert }}-pem: {% endfor %} {% endfor %} -{%- for dir, templ_path in salt_settings.cloud.template_sources.items() %} -salt-cloud-{{ dir }}: +{% for cloud_section in ["maps", "profiles", "providers"] %} +salt-cloud-{{ cloud_section }}: file.recurse: - - name: {{ salt_settings.config_path }}/cloud.{{ dir }}.d - - source: {{ templ_path }} + - name: {{ salt_settings.config_path }}/cloud.{{ cloud_section }}.d + - source: {{ salt_settings.cloud.template_sources[cloud_section] }} - template: jinja - makedirs: True -{%- endfor %} + - exclude_pat: _* -{% for key, value in cloudmaps.items() %} -/etc/salt/cloud.maps.d/{{ key }}: - file.managed: - - contents: | - {{ value|yaml(False) | indent(8) }} +{% for filename in salt['pillar.get']("salt:cloud:" ~ cloud_section, {}).keys() %} +/etc/salt/cloud.{{ cloud_section }}.d/{{ filename }}: + file.serialize: + - dataset_pillar: salt:cloud:{{ cloud_section }}:{{ filename }} + - formatter: yaml + - require: + - file: salt-cloud-{{ cloud_section }} + {%- if cloud_section == "providers" %} + - require_in: + - file: salt-cloud-providers-permissions + {%- endif %} {% endfor %} - -{% for key, value in cloudprofiles.items() %} -/etc/salt/cloud.profiles.d/{{ key }}: - file.managed: - - contents: | - {{ value|yaml(False) | indent(8) }} -{% endfor %} - -{% for key, value in cloudproviders.items() %} -/etc/salt/cloud.providers.d/{{ key }}: - file.managed: - - contents: | - {{ value|yaml(False) | indent(8) }} {% endfor %} salt-cloud-providers-permissions: @@ -108,3 +87,5 @@ salt-cloud-providers-permissions: - user - group - mode + - require: + - file: salt-cloud-providers diff --git a/salt/files/cloud.maps.d/ec2.conf b/salt/files/cloud.maps.d/_ec2.conf similarity index 100% rename from salt/files/cloud.maps.d/ec2.conf rename to salt/files/cloud.maps.d/_ec2.conf diff --git a/salt/files/cloud.maps.d/gce.conf b/salt/files/cloud.maps.d/_gce.conf similarity index 100% rename from salt/files/cloud.maps.d/gce.conf rename to salt/files/cloud.maps.d/_gce.conf diff --git a/salt/files/cloud.maps.d/rsos.conf b/salt/files/cloud.maps.d/_rsos.conf similarity index 100% rename from salt/files/cloud.maps.d/rsos.conf rename to salt/files/cloud.maps.d/_rsos.conf diff --git a/salt/files/cloud.maps.d/saltify.conf b/salt/files/cloud.maps.d/_saltify.conf similarity index 100% rename from salt/files/cloud.maps.d/saltify.conf rename to salt/files/cloud.maps.d/_saltify.conf diff --git a/salt/files/cloud.profiles.d/ec2.conf b/salt/files/cloud.profiles.d/_ec2.conf similarity index 100% rename from salt/files/cloud.profiles.d/ec2.conf rename to salt/files/cloud.profiles.d/_ec2.conf diff --git a/salt/files/cloud.profiles.d/gce.conf b/salt/files/cloud.profiles.d/_gce.conf similarity index 100% rename from salt/files/cloud.profiles.d/gce.conf rename to salt/files/cloud.profiles.d/_gce.conf diff --git a/salt/files/cloud.profiles.d/rsos.conf b/salt/files/cloud.profiles.d/_rsos.conf similarity index 100% rename from salt/files/cloud.profiles.d/rsos.conf rename to salt/files/cloud.profiles.d/_rsos.conf diff --git a/salt/files/cloud.profiles.d/saltify.conf b/salt/files/cloud.profiles.d/_saltify.conf similarity index 100% rename from salt/files/cloud.profiles.d/saltify.conf rename to salt/files/cloud.profiles.d/_saltify.conf diff --git a/salt/files/cloud.providers.d/ec2.conf b/salt/files/cloud.providers.d/_ec2.conf similarity index 100% rename from salt/files/cloud.providers.d/ec2.conf rename to salt/files/cloud.providers.d/_ec2.conf diff --git a/salt/files/cloud.providers.d/gce.conf b/salt/files/cloud.providers.d/_gce.conf similarity index 100% rename from salt/files/cloud.providers.d/gce.conf rename to salt/files/cloud.providers.d/_gce.conf diff --git a/salt/files/cloud.providers.d/rsos.conf b/salt/files/cloud.providers.d/_rsos.conf similarity index 100% rename from salt/files/cloud.providers.d/rsos.conf rename to salt/files/cloud.providers.d/_rsos.conf diff --git a/salt/files/cloud.providers.d/saltify.conf b/salt/files/cloud.providers.d/_saltify.conf similarity index 100% rename from salt/files/cloud.providers.d/saltify.conf rename to salt/files/cloud.providers.d/_saltify.conf