@@ -86,6 +86,7 @@ suites: | |||
minion_local_pillar.sls: tests/pillar/minion_local_pillar.sls | |||
minion_local_reclass.sls: tests/pillar/minion_local_reclass.sls | |||
minion_backend_urllib.sls: tests/pillar/minion_backend_urllib.sls | |||
minion_env_vars.sls: tests/pillar/minion_env_vars.sls | |||
- name: master-default | |||
provisioner: |
@@ -565,6 +565,15 @@ useful for cases where you need to set no_proxy lists. | |||
minion: | |||
backend: urllib2 | |||
Salt minion using environment variables defined in /etc/default/salt-minion for | |||
upstart based Ubuntu and in /etc/environment for Ubuntu with systemd. | |||
.. code-block:: yaml | |||
salt: | |||
minion: | |||
env_vars: | |||
engine: file | |||
Salt minion with PKI certificate authority (CA) | |||
@@ -0,0 +1,7 @@ | |||
{%- from "salt/map.jinja" import minion with context -%} | |||
{%- if minion.env_vars.variables is defined -%} | |||
{%- for envvar_name, envvar_value in minion.env_vars.get('variables', {}).iteritems() %} | |||
export {{ envvar_name }}={% if envvar_value is string -%}{{ envvar_value }}{%- else -%}{{ envvar_value|join(',') }} | |||
{%- endif %} | |||
{%- endfor %} | |||
{%- endif %} |
@@ -0,0 +1,2 @@ | |||
[Service] | |||
EnvironmentFile=/etc/environment |
@@ -148,6 +148,17 @@ RedHat: | |||
}, merge=pillar.salt.minion.get('proxy_minion', {})) %} | |||
{%- endif %} | |||
{%- if pillar.salt.minion.env_vars is defined %} | |||
{% set env_vars = salt['grains.filter_by']({ | |||
'Debian': { | |||
'engine': 'file' | |||
}, | |||
'RedHat': { | |||
'engine': 'file' | |||
}, | |||
}, merge=pillar.salt.minion.get('env_vars', {})) %} | |||
{%- endif %} | |||
{%- endif %} | |||
@@ -0,0 +1,32 @@ | |||
{%- from "salt/map.jinja" import minion,env_vars with context %} | |||
{%- if env_vars.engine is defined %} | |||
{%- if env_vars.engine == 'file' %} | |||
/etc/default/salt-minion: | |||
file.managed: | |||
- source: salt://salt/files/etc_default_salt-minion | |||
- user: root | |||
- group: root | |||
- template: jinja | |||
- require: | |||
- {{ minion.install_state }} | |||
- onchanges_in: | |||
- cmd: salt_minion_service_restart | |||
{%- if grains.get('init', None) == 'systemd' %} | |||
/etc/systemd/system/salt-minion.service.d/override.conf: | |||
file.managed: | |||
- source: salt://salt/files/systemd_minion_override.conf | |||
- user: root | |||
- makedirs: True | |||
- group: root | |||
- template: jinja | |||
- require: | |||
- {{ minion.install_state }} | |||
- onchanges_in: | |||
- cmd: salt_minion_service_restart | |||
{%- endif %} | |||
{%- endif %} | |||
{%- endif %} |
@@ -11,3 +11,6 @@ include: | |||
{%- if pillar.salt.minion.proxy_minion is defined %} | |||
- salt.minion.proxy | |||
{%- endif %} | |||
{%- if pillar.salt.minion.env_vars is defined %} | |||
- salt.minion.env_vars | |||
{%- endif %} |
@@ -0,0 +1,5 @@ | |||
salt: | |||
minion: | |||
enabled: true | |||
env_vars: | |||
engine: file |