task: persist release pillar values to values files on minion

Fixes salt-formulas/salt-formula-helm#6
diff --git a/_modules/helm.py b/_modules/helm.py
index f690b8f..087c751 100644
--- a/_modules/helm.py
+++ b/_modules/helm.py
@@ -234,7 +234,7 @@
 
 
 def release_create(name, chart_name, namespace='default',
-                   version=None, values=None,
+                   version=None, values_file=None,
                    tiller_namespace='kube-system', tiller_host=None,
                    kube_config=None, gce_service_token=None,
                    helm_home=None):
@@ -248,12 +248,10 @@
     args = []
     if version is not None:
         args += ['--version', version]
-    if values is not None:
-        args += ['--values', '/dev/stdin']
+    if values_file is not None:
+        args += ['--values', values_file]
     cmd = _helm_cmd('install', '--namespace', namespace,
                     '--name', name, chart_name, *args, **kwargs)
-    if values is not None:
-        cmd['stdin'] = yaml.serialize(values, default_flow_style=False)
     LOG.debug('Creating release with args: %s', cmd)
     return ok_or_output(cmd, 'Failed to create release "{}"'.format(name))
 
@@ -269,7 +267,7 @@
 
 
 def release_upgrade(name, chart_name, namespace='default',
-                    version=None, values=None,
+                    version=None, values_file=None,
                     tiller_namespace='kube-system', tiller_host=None,
                     kube_config=None, gce_service_token=None, helm_home=None):
     kwargs = {
@@ -281,13 +279,11 @@
     }
     args = []
     if version is not None:
-        args += ['--version', version]
-    if values is not None:
-        args += ['--values', '/dev/stdin']
+      args += ['--version', version]
+    if values_file is not None:
+      args += ['--values', values_file]
     cmd = _helm_cmd('upgrade', '--namespace', namespace,
                     name, chart_name, *args, **kwargs)
-    if values is not None:
-        cmd['stdin'] = yaml.serialize(values, default_flow_style=False)
     LOG.debug('Upgrading release with args: %s', cmd)
     return ok_or_output(cmd, 'Failed to upgrade release "{}"'.format(name))
 
diff --git a/_states/helm_release.py b/_states/helm_release.py
index 0fb6468..3c1be90 100644
--- a/_states/helm_release.py
+++ b/_states/helm_release.py
@@ -12,7 +12,7 @@
     }
 
 
-def present(name, chart_name, namespace, version=None, values=None,
+def present(name, chart_name, namespace, version=None, values_file=None,
             tiller_namespace='kube-system', tiller_host=None,
             kube_config=None, gce_service_token=None, helm_home=None):
     kwargs = {
@@ -25,7 +25,7 @@
     exists = __salt__['helm.release_exists'](name, namespace, **kwargs)
     if not exists:
         err = __salt__['helm.release_create'](
-            name, chart_name, namespace, version, values, **kwargs)
+            name, chart_name, namespace, version, values_file, **kwargs)
         if err:
             return failure(name, err)
         return {
@@ -37,7 +37,7 @@
 
     old_values = __salt__['helm.get_values'](name, **kwargs)
     err = __salt__['helm.release_upgrade'](
-        name, chart_name, namespace, version, values, **kwargs)
+        name, chart_name, namespace, version, values_file, **kwargs)
     if err:
         return failure(name, err)
 
diff --git a/helm/map.jinja b/helm/map.jinja
index 1f13529..974ed5b 100644
--- a/helm/map.jinja
+++ b/helm/map.jinja
@@ -33,6 +33,7 @@
     download_hash: sha256=ba807d6017b612a0c63c093a954c7d63918d3e324bdba335d67b7948439dbca8
     bin: /usr/bin/helm
     helm_home: /srv/helm/home
+    values_dir: /srv/helm/values
     tiller:
       install: true
       namespace: kube-system
diff --git a/helm/releases_managed.sls b/helm/releases_managed.sls
index 42e6c5a..0be9dff 100644
--- a/helm/releases_managed.sls
+++ b/helm/releases_managed.sls
@@ -10,8 +10,22 @@
 {%- for release_id, release in config.releases.items() %}
 {%- set release_name = release.get('name', release_id) %}
 {%- set namespace = release.get('namespace', 'default') %}
+{%- set values_file = None %}
+{%- if release.get('values') %}
+{%- set values_file = config.values_dir + "/" + release_name + ".yaml" %}
+{%- endif %}
+
 
 {%- if release.get('enabled', True) %}
+
+{%- if values_file %}
+{{ values_file }}:
+  file.managed:
+    - makedirs: True
+    - contents: |
+        {{ release['values'] | yaml(false) | indent(8) }}
+{%- endif %}
+
 ensure_{{ release_id }}_release:
   helm_release.present:
     - name: {{ release_name }}
@@ -24,9 +38,8 @@
     {%- if release.get('version') %}
     - version: {{ release['version'] }}
     {%- endif %}
-    {%- if release.get('values') %}
-    - values:
-        {{ release['values']|yaml(False)|indent(8) }}
+    {%- if values_file %}
+    - values_file: {{ values_file }}
     {%- endif %}
     - require:
       {%- if config.tiller.install %}
@@ -40,6 +53,13 @@
       # 
 
 {%- else %}{# not release.enabled #}
+
+{%- if values_file %}
+{{ values_file }}:
+  file.absent
+{%- endif %}
+
+
 absent_{{ release_id }}_release:
   helm_release.absent:
     - name: {{ release_name }}
diff --git a/pillar.example b/pillar.example
index 2e401ff..16e906b 100644
--- a/pillar.example
+++ b/pillar.example
@@ -20,6 +20,12 @@
     # helm_home: /srv/helm/home
 
     #
+    # The path where this formula places configuration values files on the
+    # target minion. Defaults to /srv/helm/values
+    #
+    # values_dir: /srv/helm/values
+
+    #
     # The flavor of the helm or kubectl binary to install, as informed by the
     # target minion's OS. For available flavor names, peruse the listing of
     # Helm binaries exposed at: