2
0

Merge pull request #305 from EvaSDK/salt-cloud-cleanups

salt-cloud handling cleanups
This commit is contained in:
Nitin Madhok 2017-04-23 12:47:31 -04:00 committed by GitHub
commit eb09c3bdc6
13 changed files with 26 additions and 45 deletions

View File

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