From fb1d7e8d3b22f6250d635eb48ea2e1765c5f042c Mon Sep 17 00:00:00 2001 From: Andrew Vant Date: Fri, 3 Apr 2015 17:33:25 -0400 Subject: [PATCH] Added pillar option to redirect profile and map folders. --- pillar.example | 6 ++++++ salt/cloud.sls | 22 ++++++++++------------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/pillar.example b/pillar.example index ca41f63..5076166 100644 --- a/pillar.example +++ b/pillar.example @@ -82,6 +82,12 @@ salt: - cloud.providers.d/key - cloud.profiles.d - cloud.maps.d + + # You can take profile and map templates from an alternate location + # if desired. + profiles_src: salt://templates/cloud.profiles.d + maps_src: salt://templates/cloud.maps.d + providers: - ec2 - gce diff --git a/salt/cloud.sls b/salt/cloud.sls index 9d467e7..b95c103 100644 --- a/salt/cloud.sls +++ b/salt/cloud.sls @@ -60,21 +60,19 @@ cloud-cert-{{ cert }}-pem: {% endfor %} {% for providers in salt_settings.cloud.providers %} -salt-cloud-profiles-{{ providers }}: - file.managed: - - name: /etc/salt/cloud.profiles.d/{{ providers }}.conf - - template: jinja - - source: salt://salt/files/cloud.profiles.d/{{ providers }}.conf - salt-cloud-providers-{{ providers }}: file.managed: - name: /etc/salt/cloud.providers.d/{{ providers }}.conf - template: jinja - source: salt://salt/files/cloud.providers.d/{{ providers }}.conf - -salt-cloud-maps-{{ providers }}: - file.managed: - - name: /etc/salt/cloud.maps.d/{{ providers }}.conf - - template: jinja - - source: salt://salt/files/cloud.maps.d/{{ providers }}.conf {% endfor %} + +{%- for dir in ['profiles', 'maps'] %} +{%- set default_src = 'salt://salt/files/cloud.{}.d'.format(dir) %} +{%- set source = salt_settings.cloud.get(dir + "_src", default_src) %} +salt-cloud-{{ dir }}: + file.recurse: + - name: /etc/salt/cloud.{{ dir }}.d + - source: {{ source }} + - template: jinja +{%- endfor %}