소스 검색

Adding environment variables for salt minion

salt-minion started via upstart is not using /etc/environment to
source variables therefore is not using system wide http_proxy parameters if
they are set there. With this patch if salt.minion.env_vars is set to engine:
file salt will set envvars in /etc/default/salt-minion and will use them for
all commands executed remotely via salt. Since /etc/default is not used on
systems with systemd override for salt-minion to use /etc/environmnet will be
set.

Change-Id: Icfe122de2486a83820a0bd2e2aeea4be3796c6aa
Closes-bug: PROD-16676
pull/73/head
Marcin Iwinski 7 년 전
부모
커밋
03560d7e1e
8개의 변경된 파일70개의 추가작업 그리고 0개의 파일을 삭제
  1. +1
    -0
      .kitchen.yml
  2. +9
    -0
      README.rst
  3. +7
    -0
      salt/files/etc_default_salt-minion
  4. +2
    -0
      salt/files/systemd_minion_override.conf
  5. +11
    -0
      salt/map.jinja
  6. +32
    -0
      salt/minion/env_vars.sls
  7. +3
    -0
      salt/minion/init.sls
  8. +5
    -0
      tests/pillar/minion_env_vars.sls

+ 1
- 0
.kitchen.yml 파일 보기

@@ -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:

+ 9
- 0
README.rst 파일 보기

@@ -521,6 +521,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)


+ 7
- 0
salt/files/etc_default_salt-minion 파일 보기

@@ -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 %}

+ 2
- 0
salt/files/systemd_minion_override.conf 파일 보기

@@ -0,0 +1,2 @@
[Service]
EnvironmentFile=/etc/environment

+ 11
- 0
salt/map.jinja 파일 보기

@@ -147,6 +147,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 %}



+ 32
- 0
salt/minion/env_vars.sls 파일 보기

@@ -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 %}

+ 3
- 0
salt/minion/init.sls 파일 보기

@@ -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 %}

+ 5
- 0
tests/pillar/minion_env_vars.sls 파일 보기

@@ -0,0 +1,5 @@
salt:
minion:
enabled: true
env_vars:
engine: file

Loading…
취소
저장