2
0

Merge pull request #117 from andrew-vant/cloud-templates-redirect

Added pillar option to redirect profile and map folders.
This commit is contained in:
Brian Jackson 2015-04-14 11:34:12 -05:00
commit 15e63e8fd0
7 changed files with 52 additions and 49 deletions

View File

@ -78,13 +78,16 @@ salt:
# salt cloud config # salt cloud config
cloud: cloud:
master: salt master: salt
folders:
- cloud.providers.d/key # You can take profile and map templates from an alternate location
- cloud.profiles.d # if you want to write your own.
- cloud.maps.d template_sources:
providers: providers: salt://salt/files/cloud.providers.d
- ec2 profiles: salt://salt/files/cloud.profiles.d
- gce maps: salt://salt/files/cloud.maps.d
# These settings are used by the default provider templates and
# only need to be set for the ones you're using.
aws_key: AWSKEYIJSHJAIJS6JSH aws_key: AWSKEYIJSHJAIJS6JSH
aws_secret: AWSSECRETYkkDY1iQf9zRtl9+pW+Nm+aZY95 aws_secret: AWSSECRETYkkDY1iQf9zRtl9+pW+Nm+aZY95
gce_project: test gce_project: test

View File

@ -32,49 +32,40 @@ salt-cloud:
{% endif %} {% endif %}
{% endif %} {% endif %}
{% for folder in salt_settings.cloud.folders %}
{{ folder }}:
file.directory:
- name: /etc/salt/{{ folder }}
- user: root
- group: root
- file_mode: 744
- dir_mode: 755
- makedirs: True
{% endfor %}
{% for cert in pillar.get('salt_cloud_certs', {}) %} {% for cert in pillar.get('salt_cloud_certs', {}) %}
{% for type in ['pem'] %} {% for type in ['pem'] %}
cloud-cert-{{ cert }}-pem: cloud-cert-{{ cert }}-pem:
file.managed: file.managed:
- name: /etc/salt/cloud.providers.d/key/{{ cert }}.pem - name: /etc/salt/pki/cloud/{{ cert }}.pem
- source: salt://salt/files/key - source: salt://salt/files/key
- template: jinja - template: jinja
- user: root - user: root
- group: root - group: root
- mode: 600 - mode: 600
- makedirs: True
- defaults: - defaults:
key: {{ cert }} key: {{ cert }}
type: {{ type }} type: {{ type }}
{% endfor %} {% endfor %}
{% endfor %} {% endfor %}
{% for providers in salt_settings.cloud.providers %} {%- for dir, templ_path in salt_settings.cloud.template_sources.items() %}
salt-cloud-profiles-{{ providers }}: salt-cloud-{{ dir }}:
file.managed: file.recurse:
- name: /etc/salt/cloud.profiles.d/{{ providers }}.conf - name: /etc/salt/cloud.{{ dir }}.d
- source: {{ templ_path }}
- template: jinja - template: jinja
- source: salt://salt/files/cloud.profiles.d/{{ providers }}.conf - makedirs: True
{%- endfor %}
salt-cloud-providers-{{ providers }}: salt-cloud-providers-permissions:
file.managed: file.directory:
- name: /etc/salt/cloud.providers.d/{{ providers }}.conf - name: /etc/salt/cloud.providers.d
- template: jinja - user: root
- source: salt://salt/files/cloud.providers.d/{{ providers }}.conf - group: root
- file_mode: 600
salt-cloud-maps-{{ providers }}: - dir_mode: 700
file.managed: - recurse:
- name: /etc/salt/cloud.maps.d/{{ providers }}.conf - user
- template: jinja - group
- source: salt://salt/files/cloud.maps.d/{{ providers }}.conf - mode
{% endfor %}

View File

@ -23,3 +23,9 @@ salt:
install_from_source: True install_from_source: True
gitpython: gitpython:
install_from_source: False install_from_source: False
cloud:
template_sources:
providers: salt://salt/files/cloud.providers.d
profiles: salt://salt/files/cloud.profiles.d
maps: salt://salt/files/cloud.maps.d

View File

@ -2,13 +2,13 @@
{% set cloud = salt['pillar.get']('salt:cloud', {}) -%} {% set cloud = salt['pillar.get']('salt:cloud', {}) -%}
ec2_ubuntu_public: ec2_ubuntu_public:
minion: minion:
master: {{ cloud['master'] }} master: {{ cloud.get('master', 'salt') }}
grains: grains:
test: True test: True
ssh_interface: public_ips ssh_interface: public_ips
id: {{ cloud['aws_key'] }} id: {{ cloud.get('aws_key', 'DEFAULT') }}
key: '{{ cloud['aws_secret'] }}' key: '{{ cloud.get('aws_secret', 'DEFAULT') }}'
private_key: /etc/salt/cloud.providers.d/key/key.pem private_key: /etc/salt/pki/cloud/ec2.pem
keyname: keyname keyname: keyname
location: eu-west-1 location: eu-west-1
availability_zone: eu-west-1a availability_zone: eu-west-1a

View File

@ -1,11 +1,11 @@
# This file managed by Salt, do not edit by hand!! # This file managed by Salt, do not edit by hand!!
{% set cloud = salt['pillar.get']('salt:cloud', {}) -%} {% set cloud = salt['pillar.get']('salt:cloud', {}) -%}
gce: gce:
project: "{{ cloud['gce_project'] }}" project: "{{ cloud.get('gce_project', 'DEFAULT') }}"
service_account_email_address: "{{ cloud['gce_service_account_email_address'] }}" service_account_email_address: "{{ cloud.get('gce_service_account_email_address', 'DEFAULT') }}"
service_account_private_key: "/etc/salt/cloud.providers.d/key.pem" service_account_private_key: "/etc/salt/pki/cloud/gce.pem"
minion: minion:
master: {{ cloud['master'] }} master: {{ cloud.get('master', 'salt') }}
grains: grains:
test: True test: True
provider: gce provider: gce

View File

@ -6,7 +6,7 @@
rsos_{{ region|lower }}: rsos_{{ region|lower }}:
minion: minion:
master: {{ cloud['master'] }} master: {{ cloud.get('master', 'salt') }}
grains: grains:
region: {{ region|lower }} region: {{ region|lower }}
@ -15,7 +15,7 @@ rsos_{{ region|lower }}:
protocol: ipv4 protocol: ipv4
compute_region: {{ region }} compute_region: {{ region }}
provider: openstack provider: openstack
user: {{ cloud['rsos_user'] }} user: {{ cloud.get('rsos_user', 'DEFAULT') }}
tenant: {{ cloud['rsos_tenant'] }} tenant: {{ cloud.get('rsos_tenant', 'DEFAULT') }}
apikey: {{ cloud['rsos_apikey'] }} apikey: {{ cloud.get('rsos_apikey', 'DEFAULT') }}
{% endfor %} {% endfor %}

View File

@ -1,5 +1,8 @@
# This file is managed by Salt via {{ source }} # This file is managed by Salt via {{ source }}
{% set cloud = salt['pillar.get']('salt:cloud', {}) -%}
saltify: saltify:
provider: saltify provider: saltify
minion: minion:
master: {{ cloud['master'] }} master: {{ cloud.get('master', 'salt') }}