2015-03-17 05:39:32 +01:00
|
|
|
{% from "salt/map.jinja" import salt_settings with context %}
|
2014-07-20 16:59:38 +02:00
|
|
|
|
2016-09-20 05:38:01 +02:00
|
|
|
{%- if salt_settings.use_pip %}
|
2014-07-20 16:59:38 +02:00
|
|
|
python-pip:
|
|
|
|
pkg.installed
|
|
|
|
|
2017-04-10 09:54:56 +02:00
|
|
|
salt-cloud-pip-packages:
|
2014-07-20 16:59:38 +02:00
|
|
|
pip.installed:
|
2017-04-10 09:54:56 +02:00
|
|
|
- pkgs:
|
|
|
|
- apache-libcloud
|
|
|
|
{%- if grains['os_family'] not in ['Debian', 'RedHat'] %}
|
|
|
|
- crypto
|
|
|
|
{%- endif %}
|
|
|
|
- pycrypto
|
2014-07-20 16:59:38 +02:00
|
|
|
- require:
|
|
|
|
- pkg: python-pip
|
2016-09-20 05:38:01 +02:00
|
|
|
{%- endif %}
|
2014-07-20 16:59:38 +02:00
|
|
|
|
2015-03-24 18:08:08 +01:00
|
|
|
{% if salt_settings.install_packages %}
|
2014-07-20 16:59:38 +02:00
|
|
|
salt-cloud:
|
|
|
|
pkg.installed:
|
2015-03-17 05:39:32 +01:00
|
|
|
- name: {{ salt_settings.salt_cloud }}
|
2016-09-20 05:38:01 +02:00
|
|
|
{%- if salt_settings.use_pip %}
|
2014-07-20 16:59:38 +02:00
|
|
|
- require:
|
2017-04-10 09:54:56 +02:00
|
|
|
- pip: salt-cloud-pip-packages
|
2016-09-20 05:38:01 +02:00
|
|
|
{%- endif %}
|
2015-03-24 18:08:08 +01:00
|
|
|
{% endif %}
|
2014-07-20 16:59:38 +02:00
|
|
|
|
2015-03-30 19:54:50 +02:00
|
|
|
{% for cert in pillar.get('salt_cloud_certs', {}) %}
|
2014-07-20 16:59:38 +02:00
|
|
|
{% for type in ['pem'] %}
|
|
|
|
cloud-cert-{{ cert }}-pem:
|
|
|
|
file.managed:
|
2016-03-29 19:28:47 +02:00
|
|
|
- name: {{ salt_settings.config_path }}/pki/cloud/{{ cert }}.pem
|
2015-06-09 23:05:49 +02:00
|
|
|
- source: salt://{{ slspath }}/files/key
|
2014-07-20 16:59:38 +02:00
|
|
|
- template: jinja
|
|
|
|
- user: root
|
2017-01-13 13:52:18 +01:00
|
|
|
- group:
|
|
|
|
{%- if grains['kernel'] in ['FreeBSD', 'OpenBSD', 'NetBSD'] %}
|
|
|
|
wheel
|
|
|
|
{%- else %}
|
|
|
|
root
|
|
|
|
{%- endif %}
|
2014-07-20 16:59:38 +02:00
|
|
|
- mode: 600
|
2015-04-04 01:30:26 +02:00
|
|
|
- makedirs: True
|
2014-07-20 16:59:38 +02:00
|
|
|
- defaults:
|
|
|
|
key: {{ cert }}
|
|
|
|
type: {{ type }}
|
|
|
|
{% endfor %}
|
|
|
|
{% endfor %}
|
|
|
|
|
2017-04-10 11:20:43 +02:00
|
|
|
{% for cloud_section in ["maps", "profiles", "providers"] %}
|
|
|
|
salt-cloud-{{ cloud_section }}:
|
2015-04-03 23:33:25 +02:00
|
|
|
file.recurse:
|
2017-04-10 11:20:43 +02:00
|
|
|
- name: {{ salt_settings.config_path }}/cloud.{{ cloud_section }}.d
|
|
|
|
- source: {{ salt_settings.cloud.template_sources[cloud_section] }}
|
2014-07-20 16:59:38 +02:00
|
|
|
- template: jinja
|
2015-04-04 01:30:26 +02:00
|
|
|
- makedirs: True
|
2017-04-11 13:30:23 +02:00
|
|
|
- exclude_pat: _*
|
2015-04-06 17:24:41 +02:00
|
|
|
|
2017-04-10 11:20:43 +02:00
|
|
|
{% 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 %}
|
2016-05-06 20:45:41 +02:00
|
|
|
{% endfor %}
|
|
|
|
{% endfor %}
|
|
|
|
|
2015-04-06 17:24:41 +02:00
|
|
|
salt-cloud-providers-permissions:
|
|
|
|
file.directory:
|
2016-03-29 19:28:47 +02:00
|
|
|
- name: {{ salt_settings.config_path }}/cloud.providers.d
|
2015-04-06 17:24:41 +02:00
|
|
|
- user: root
|
2017-01-13 13:52:18 +01:00
|
|
|
- group:
|
|
|
|
{%- if grains['kernel'] in ['FreeBSD', 'OpenBSD', 'NetBSD'] %}
|
|
|
|
wheel
|
|
|
|
{%- else %}
|
|
|
|
root
|
|
|
|
{%- endif %}
|
2015-04-06 17:24:41 +02:00
|
|
|
- file_mode: 600
|
|
|
|
- dir_mode: 700
|
|
|
|
- recurse:
|
|
|
|
- user
|
|
|
|
- group
|
|
|
|
- mode
|
2017-04-10 11:20:43 +02:00
|
|
|
- require:
|
|
|
|
- file: salt-cloud-providers
|